select 1 from table 中的1是一常量(可以为任意数值),查到的所有行的值都是它,但从效率上来说,select 1 > select xxx > select *,因为不用查字典表。
case 字段名 when 条件 then 值 else 值 end SELECT name = case when a.colorder = 1 then d.name else '' end
多表查询更新数据
UPDATE t_community o
INNER JOIN t_community_bat p ON o.`code`=p.`code`
SET o.remark=p.remark