Quantcast
Channel: moovendan » MYSQL
Browsing latest articles
Browse All 6 View Live

Image may be NSFW.
Clik here to view.

Get random value from mysql

Method 1 $result = mysql_query('SELECT COUNT(*) FROM quotes'); $count = mysql_fetch_row($result); $id = rand(1, $count[0]); $result = mysql_query("SELECT author, quote FROM quotes WHERE id=$id");...

View Article



Image may be NSFW.
Clik here to view.

mysql query with if statement

SELECT (CASE WHEN columna = 887 THEN columnb ELSE columna END) AS 'columnAlias' FROM <table> WHERE columna = 887 OR columnb = 887 or select if( b.initiator_user_id = 2, b.friend_user_id,...

View Article

Image may be NSFW.
Clik here to view.

users and usermeta – joining multiple rows in one table to one row in another...

SELECT u1.id, u1.login, u1.password, u1.email, m1.meta_value AS firstname, m2.meta_value AS lastname, m3.meta_value AS country FROM wp_users u1 JOIN wp_usermeta m1 ON (m1.user_id = u1.id AND...

View Article

Image may be NSFW.
Clik here to view.

search-users-base-on-meta-value-meta-key

$query = "SELECT user_id FROM $wpdb->usermeta WHERE (meta_value LIKE '%%david%%') AND (meta_key = 'first_name') AND user_id IN (SELECT user_id FROM $wpdb->usermeta WHERE (meta_value LIKE...

View Article

Image may be NSFW.
Clik here to view.

intelligent-mysql-group-by-for-activity-streams

http://stackoverflow.com/questions/14004322/intelligent-mysql-group-by-for-activity-streams   I’m building an activity stream for our site, and have made some decent headway with something that works...

View Article


Image may be NSFW.
Clik here to view.

Mysql Random

SELECT * FROM (`challenge_info_tips`) WHERE `info_type` = '1' AND `info_status` = 1 ORDER BY RAND() LIMIT 4   SELECT * FROM (SELECT info_id FROM challenge_info_tips ORDER BY RAND() LIMIT 4) AS...

View Article
Browsing latest articles
Browse All 6 View Live




Latest Images