原文地址:https://www.douyacun.com/article/276f1fe261eee4d9bda2b8da10d19e2c
GROUP_CONCAT(DISTINCT expression
ORDER BY expression
SEPARATOR sep);
mysql> INSERT INTO t(v) VALUES('A'),('B'),('C'),('B');
mysql> select group_concat(
distinct v
order by v desc
separator ';')
from t;
mysql> d;c;b;a
CASE value
WHEN compare_value_1 THEN result_1
WHEN compare_value_2 THEN result_2
…
ELSE result
END
CASE
WHEN state IS NULL THEN country
ELSE state
END
mysql> select
case phone
when 15258157582 then 1234567
else phone end
from ln_users;
IF expression THEN
statements;
END IF;
SELECT IFNULL(1,0); -- returns 1
SELECT IFNULL('',1); -- returns ''
select ifnull(email,concat(phone,'@abc.com') as email from ln_users;
mysql> select nullif(phone,15258157582) as phone from ln_users;
select date_format(create_at,'%Y-%m-%d') from ln_users;
SELECT STR_TO_DATE('21,5,2018','%d,%m,%Y');
SELECT TIMEDIFF('12:00:00','10:00:00') diff;