优秀的编程知识分享平台

网站首页 > 技术文章 正文

「学习笔记」SQL模糊查询like、范围between、in包含

nanyue 2024-07-25 05:50:45 技术文章 12 ℃

like配合使用的%、 _ 、[ ] 、[^ ]


比较范围判断

select * from Students
where Birthday>'2000-1-1' and Birthday<'2020-12-31'

这样是比较了两次,下面使用BETWEEN,以物理磁盘索引顺序去检索 a-z 0-9,执行效率高

select * from Students
where Birthday between '2000-1-1' and '2020-12-31'

between这个关键词写的时候,一定是数值小的在前面大的在后面不能颠倒

上面的例子中,就是2000-1-1在左边,在前面。右边2020-12-31一定是放在后面,而不能放在前面(左边)


in()包含什么什么

not in() 取反

Tags:

最近发表
标签列表