您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

在获取数据作为输出时,如何在同一列上使用多个条件?

2024/4/13 12:34:32发布11次查看
以下是我们编写查询的方法,该查询仅返回与同一列上的多个条件匹配的记录
通过使用“or”逻辑运算符众所周知,mysql 的“or”运算符比较两个表达式,如果其中一个表达式为 true,则返回 true。以下示例演示了如何对同一列上的多个条件使用“or”运算符
mysql> select * from student where name = 'gaurav' or name = 'aarav';+------+--------+---------+-----------+| id | name | address | subject |+------+--------+---------+-----------+| 1 | gaurav | delhi | computers || 2 | aarav | mumbai | history |+------+--------+---------+-----------+2 rows in set (0.00 sec)
通过使用 where in(…) 子句where in(…) 子句也用于上述目的。它可以在同一列上的多个条件的查询中使用,如下所示 -
mysql> select * from student where name in ('gaurav','aarav');+------+--------+---------+-----------+| id | name | address | subject |+------+--------+---------+-----------+| 1 | gaurav | delhi | computers || 2 | aarav | mumbai | history |+------+--------+---------+-----------+2 rows in set (0.00 sec)
以上就是在获取数据作为输出时,如何在同一列上使用多个条件?的详细内容。
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product