sql 高級 (一) (top子句 like 通配符 IN between )

top子句spa

eg:ci

        select * from persons limit 5
it

        select * from persons where rownum<=5
ast

        select top 2 * from persons (從"Persons" 表中選取頭兩條記錄
select

        select top 50 percent * from persons (從"Persons" 表中選取 50% 的記錄)im

like操做符數據

eg:margin

        select * from Persons where city not like '%lon%'
top

通配符img

    

        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'

相關文章
相關標籤/搜索