zoukankan      html  css  js  c++  java
  • 《mysql必知必会》学习_第七章

    第七章:数据过滤

    P43

    select prod_id,prod_price,prod_name from products where vend_id =1003 and prod_price <=10;  #检索vend_id=1003 并且prod_price<=10 #

    select prod_name,prod_price from products where vend_id=1002 or vend_id =1003; #检索的条件只要满足vend_id=1002 ,vend_id=1003即可#

    P42

    select prod_name,prod_price from products where vend_id =1002 or vend_id=1003 and prod_price >=10;#and和or同时存在的时候,优先处理and的操作符,理解为两个条件:(vend_id=1002) or(vend_id =1003 and prod_price) ,满足其一即可。

    P42

    select prod_name,prod_price from products where (vend_id =1002 or vend_id =1003 ) and prod_price>=10; #执行两个命令:(vend_id=1002,vend_id=1003)和prod_price>=10,圆括号()的命令优先级高于and和or #

    P43 in操作符 (in取合法值有逗号分开,如(5,8) )

    select prod_name,prod_price from products where vend_id in (1002,1003) order by prod_name; #检索的条件vend_id 在1002到1003这个范围内#因为vend_id都是整数,所以上面的语句的结果和这个一样:

    select prod_name,prod_price from products where vend_id=1002 or vend_id=1003 order by prod_name; 

    但注意,in命令比or执行更快。

    P45 

     select prod_name,prod_price from products where vend_id not in (1002,1003) order by prod_name; #not否定了not后面的条件,不检索(1002,1003) #

  • 相关阅读:
    基于摸板匹配的目標跟蹤算法
    spoj 2713 Can you answer these queries IV
    zoj 3633 Alice's present
    hdu 3642 Get The Treasury
    poj 1195 Mobile phones
    poj 2760 End of Windless Days
    zoj 3540 Adding New Machine
    spoj 1716 Can you answer these queries III
    spoj 1043 Can you answer these queries I
    spoj 2916 Can you answer these queries V
  • 原文地址:https://www.cnblogs.com/qiyuanjiejie/p/9392389.html
Copyright © 2011-2022 走看看