zoukankan      html  css  js  c++  java
  • sql server 2005 (select查询语句用法)

    select * from userInfo where age like '2[25]'

    功能:查询userInfo表中age字段,所有以2开头,且第二位是2或5的记录。

     

    select * from userInfo where name like '_娜_'

    功能:查询userInfo表中name(char(6))字段所有中间一个字是“娜”的记录。下划线“_”代表的是两个任意字符,如上:名为“谢娜娜”或“谢娜”等的记录将会被查询出来

     

    select * from userInfo where address like '%川%'

    功能:查询userInfo表中address字段所有包含“川”字的记录

     

    select * from userInfo where name like '[m-n]%'

    功能:查询所有userInfo表中所有name字段是以m或n开头的记录

     

    select * from userInfo where name like 'm[^i]%'

    功能:查询userInfo表中name字段所有以m开头、第2个字母不是字母c的名称

     

    select * from userInfo where ID in(1,2)

    功能:查询userInfo表中所有ID等于1或者2的记录

    等同于

    select * from userInfo where ID='1' or ID='2'

     

    select * from userInfo where memo like '20/%' escape '/'

    功能:查询memo字段值为20%的所有记录,但是在sql Server里面%为通配符如果不加就会有其他意思

    例如:select * from userInfo where memo like '2%'   就跟上面查到一样的记录,这一句的功能是查到memo字段的值以2开头的记录。20%也是以2开头的。这样就会出现问题。所以用转义字符还是很必要的。

     

    select count(distinct ProdID) '产品种类' from userInfo

    功能:查询出来有多少种产品,distinct就是查询不重复的记录,加上count()就是不重复的记录的总数了

  • 相关阅读:
    git 记录
    js 技巧
    首页三张幻灯片放什么
    6系统盈利方向
    WordPress获取某个分类关联的标签
    目标型长尾如何优化
    简介如何去除WordPress主题版权保护的方法
    2017.7.7 长尾关键词系统优化
    2017.7.6 目标关键词分析
    2017.7.2 seo知识总纲
  • 原文地址:https://www.cnblogs.com/toge/p/6114734.html
Copyright © 2011-2022 走看看