码迷,mamicode.com
首页 > 数据库 > 详细

sql 高级

时间:2015-08-03 23:03:55      阅读:370      评论:0      收藏:0      [点我收藏+]

标签:

top子句

eg:

        select * from persons limit 5

        select * from persons where rownum<=5

        select top 2 * from persons (从"Persons" 表中选取头两条记录

        select top 50 percent * from persons (从"Persons" 表中选取 50% 的记录)

like操作符

eg:

        select * from Persons where city not like ‘%lon%‘

通配符

    技术分享

        select * from Persons where city like ‘%lond%‘

        select * from Persons where firstname like ‘_eorge‘

        select * from Persons where lastname like ‘c_r_er‘

        select * from persons where city like ‘[ALN]%‘  (从 "Persons" 表中选取居住的城市以 "A" 或 "L" 或 "N" 开头的人)

        select * from persons where city like ‘[!ALN]%‘  (从 "Persons" 表中选取居住的城市不以 "A" 或 "L" 或 "N" 开头的人)

IN操作符

        IN操作符允许我们在where子句中规定多个值

        eg:select * from persons where lastname in(‘adams‘,‘carter‘)

between 操作符

        操作符  between  ...and会选取介于两个值之间的数据范围,这些值可以是数值、文本、或者日期

        select * from persons where lastname between ‘adams‘ and ‘carter‘

        select * from persons where lastname not between ‘adams‘ and ‘carter‘




sql 高级

标签:

原文地址:http://my.oschina.net/u/2356966/blog/487265

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!