Home  >  Article  >  Database  >  How to use logical operator combinations when creating MySQL views?

How to use logical operator combinations when creating MySQL views?

WBOY
WBOYforward
2023-09-09 10:09:11549browse

在创建 MySQL 视图时如何使用逻辑运算符组合?

#MySQL views can be created by using a combination of logical operators such as AND, OR, and NOT. This can be explained with the help of the following example -

Example

mysql> Create or Replace View Info AS select ID, Name, Address , Subject FROM Student_info WHERE (Subject = 'Computers' AND ADDRESS = 'Delhi') OR (Subject = 'History' AND Address = 'Amritsar');
Query OK, 0 rows affected (0.11 sec)

mysql> Select * from Info;
+------+-------+---------+-----------+
| ID   | Name  | Address | Subject   |
+------+-------+---------+-----------+
| 133  | Mohan | Delhi   | Computers |
+------+-------+---------+-----------+
1 row in set (0.00 sec)

The above is the detailed content of How to use logical operator combinations when creating MySQL views?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:tutorialspoint.com. If there is any infringement, please contact admin@php.cn delete