zoukankan      html  css  js  c++  java
  • 数据库查询

    use mydb

    select *from Category where Parent='013' or parent='011' or Parent='012'

    --in 代表在某些参数范围之内的都符合条件,相当于多个or

    select *from Category where Parent in('013','011','012')

    --not 起修饰作用,取反

    select *from Category where Parent not in ('013','011','012')

    --between and 表示在某范围之内,相当于>= <=

    select *from Category where Ids>500 and Ids<505

    select *from Category where Ids between 500 and 505

    --模糊查询,行业里带国家两个字的 like

    select *from Category where Name like'%国家%'

    select *from Category where Name like'国家%'

    select *from Category where Name like'%机构%'

    --查询某一列里带国家两个字用'%国家%'

    --查询某一列里带国家两个字开头的'国家%"

    --查询某一列里以国家结尾'%国家'

    --不带某个字的not like

    select *from Category where Name not like '%国家%'

    --查询某一列,用列名代替*

    select code ,name from Category where Ids >5 and Ids <10

    select code from Category where Ids >5 and Ids <10

    select Ids from Category where Ids in (6,7,8,9)

    select *from Category where Ids>all

    (

    select Ids from Category where Ids in (6,7,8,9)

    )

    select *from Category where Ids>all

    (

    select Ids from Category where Ids>1190 and Ids <1195

    )

    --查询一列当作参数使用

    -->any大于查询出来的任何一个(最小数)

    -->all大于查询出来的所有的(最大数)

  • 相关阅读:
    3.5——课题选择
    3.8——K-th Substring
    01背包dp
    贪心——IQ
    Secret Project Gym
    快速幂&矩阵快速幂
    用栈非递归实现fib数列
    CodeForces Round #590 (Div 3)
    SQL Server常见问题
    SQL基础函数
  • 原文地址:https://www.cnblogs.com/yangyue/p/4120178.html
Copyright © 2011-2022 走看看