MySQL常用功能
--查询分组最大值
SELECT * FROM `myTable` WHERE `val` IN (SELECT MAX(`val`) FROM `myTable` GROUP BY `id`) ORDER BY `id` ASC LIMIT 10
SELECT * FROM `myTable` WHERE `val` IN (SELECT MAX(`val`) FROM `myTable` GROUP BY `id`) ORDER BY `id` ASC LIMIT 10
--CAST转换数据类型,DATE_FORMAT控制时间格式,DATE_ADD做时间运算
SELECT CAST(DATE_FORMAT(DATE_ADD(NOW(),INTERVAL -1 DAY),'%Y%m%d') AS SIGNED INTEGER)
SELECT CAST(DATE_FORMAT(DATE_ADD(NOW(),INTERVAL -1 DAY),'%Y%m%d') AS SIGNED INTEGER)
select case 1
when 1
then '一'
when 2
then '二'
else '三'
end;
when 1
then '一'
when 2
then '二'
else '三'
end;