日,手贱点了下360的清洁球关掉了,没保存
问题:
1.分组显示前多少个?
2.for 和 for each区别 foreach一次锁定不能增删
3.避免in not in
select * from t1 where f2 not in (select ff2 from t2);
代替:
select f1,f2 from t1 left join t2 on t1.f2 = t2.ff2 where t2.ff2 is null; where 换成and不可以 left 不能去掉
或者
select * from t1 where not EXISTS (select ff2 from t2 where t2.ff2 = t1.f2);
4.#{}和${}场景和区别
#{}底层preparedstatement 占位符 ${}底层statement 字符串拼接,不能防止sql注入;因此尽量用#{} ,动态表名要用${},有的博客说order by +字段也要用${},但是可以单引字段,不知道#{}是不是解释成双引号
5.锁表 不会问问别人,没查到
6.四则运算
7.一条sql语句执行时间过长怎么解决 不会问问别人,没查到