1.如果对字符串中下划线、百分号做匹配,可以使用ESCAPE关键字。
1
select * from customers
2
where customer_id like '%a\_product%' escape '\';
2.当 NOT IN处理一个包含NULL的列表时,不会返回任何结果。
select * from customers2
where customer_id like '%a\_product%' escape '\';
1
select * from customers where
2
customer_id not in (2,3,5,null);
3.在ORDER BY子句中,也可以按照第几列排序。1代表第一列,2代表第二列,以此类推
select * from customers where2
customer_id not in (2,3,5,null);
1
select * from customers order by 1;
4.
select * from customers order by 1;
本文介绍了在SQL查询中使用的几个实用技巧:如何通过ESCAPE关键字精确匹配字符串中的特殊字符;NOT IN操作符处理NULL值时的行为特点;以及如何利用ORDER BY子句中的数字参数按指定列排序。

被折叠的 条评论
为什么被折叠?



