Sql 杂文

1.[b]case when[/b]实例:
select a.sal,a.job
from (select b.sal,CASE job WHEN 'SALESMAN' THEN '销售' WHEN 'MANAGER' THEN '经理' ELSE '职员' END job from emp b) a
where a.job = '职员'
也可以使用下面的写法
select a.sal,a.job
from (select b.sal,CASE WHEN job='SALESMAN' THEN '销售' WHEN job='MANAGER' THEN '经理' ELSE '职员' END job from emp b) a
where a.job = '职员'
2.sql关联子查询执行时的顺序是先拿出外层的一条sql语句,然后再将该数据传递给内存查询,判断后,再去外层sql语句拿第二条语句。
如:
select id,clientVersion from statisticsession a where a.id in (select b.id from statisticsession b where b.clientVersion =a.clientVersion order by b.id desc)

mysql:导入数据
LOAD DATA INFILE 'D:/zhong/zhong.csv' INTO TABLE tableName FIELDS TERMINATED BY ',' (field,field2);

你可能感兴趣的:(sql部分)