最大的猫,甜性涩爱情完整版 优酷,农村老年人保险
and 和 or 运算符用于基于一个以上的条件对记录进行过滤。
and 和 or 可在 where 子语句中把两个或多个条件结合起来。
如果第一个条件和第二个条件都成立,则 and 运算符显示一条记录。
如果第一个条件和第二个条件中只要有一个成立,则 or 运算符显示一条记录。
lastname | firstname | address | city |
---|---|---|---|
adams | john | oxford street | london |
bush | george | fifth avenue | new york |
carter | thomas | changan street | beijing |
carter | william | xuanwumen 10 | beijing |
使用 and 来显示所有姓为 "carter" 并且名为 "thomas" 的人:
select * from persons where firstname='thomas' and lastname='carter'
lastname | firstname | address | city |
---|---|---|---|
carter | thomas | changan street | beijing |
使用 or 来显示所有姓为 "carter" 或者名为 "thomas" 的人:
select * from persons where firstname='thomas' or lastname='carter'
lastname | firstname | address | city |
---|---|---|---|
carter | thomas | changan street | beijing |
carter | william | xuanwumen 10 | beijing |
我们也可以把 and 和 or 结合起来(使用圆括号来组成复杂的表达式):
select * from persons where (firstname='thomas' or firstname='william') and lastname='carter'
lastname | firstname | address | city |
---|---|---|---|
carter | thomas | changan street | beijing |
carter | william | xuanwumen 10 | beijing |
如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复
数据库SQL---数据库、基本表、视图、索引的定义、修改、删除
在 Azure CentOS VM 中配置 SQL Server 2019 AG - (上)
在 Azure CentOS VM 中配置 SQL Server 2019 AG - (下)
网友评论