mysql 句法:
目录
mysql 句法:
交换sex的内容(m -> f, f -> m)
交换sex的内容(m -> f, f -> m)
update salary set sex = (if(sex="m", "f", "m"));
update salary set sex = char(ascii('m') + ascii('f') - ascii(sex));
UPDATE salary SET sex = CASE sex WHEN 'm' THEN 'f' ELSE 'm' end;
update salary set sex = case sex when 'm' then 'f' when 'f' then 'm' end
查询同一特征的第一条数据
select sname from students where ssex = "男" group by ssex;
联合查询
select Sname, Sage, Ssex, sc.Cnum, score, Cname from student join sc on student.Snum = sc.Snum join course on course.Cnum = sc.Cnum;