1、分组查询,并将组内的某个字段值用逗号连接起来作为一个新的字段,例如:
select url,group_concat(type_name) as type_names from music_type group by url
即把同一个url下面的type_name字段值用逗号连接起来。
2、IF函数,select中的IF函数表示的意思是 if(A=B,0,other),即如果A等于B则返回0,否则返回other,例如:
SELECT IF(userid IS NOT NULL AND userid !='null' AND userid !='',userid,
IF(sid IS NOT NULL AND sid !='null' AND sid !='',sid,'unknow')) AS id ,
DATE(log_date) AS d FROM result_log ORDER BY DATE(log_date)