SqlServer query in Session Four

Today we are speaking of command parameters in sql

in

  • --in used to query a field designated recorded information value of
    note: - on or (or) and is negated (and), and on (and) is negated or (or
    database is not the same as saying there are two types:! = <> The second recommended

    Here we analyze in detail this subject in

    Find wage (1500,3000,5000) employee information in the emp table in scott library
select * from emp 
    where sal in(1500,3000,5000)
--等价于下面语句
select * from emp 
    where sal=1500 or sal=3000 or sal=5000
         //这个sql命令首先会执行from emp找到emp这个表,然后执行where后面的语句
         //从第一条记录开始,如果sal(工资)这一个字段的值等于1500,或者3000,
         //或者5000,那就输出这条记录所有字段的值。如果不等于这些值,那就不进行输出。

The following figure is the result of the above two commands executed sql

  • We can find sal value of this field is either equal to 1500 or 3000 is equal to or equal to 5000

*** Here we look at a topic to have a full understanding of this in parameter ***

select * from emp 
    where sal in(1500,3000,5000);
--等价于下面语句
select * from emp 
    where sal=1500 or sal=3000 or sal=5000
          //这个执行的顺序和上面的一样

The following figure is the result of the above two commands executed sql

  • We can see the value of this field and so neither sal and 1500, it does not mean 3000, not equal to 5000
    today in this lecture, we will stop here, the next lecture usage parameters top of us,
    if you have any I know you can add qq485536603 ***

Guess you like

Origin www.cnblogs.com/zjlk/p/11873373.html