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

How to use logical operator combinations when creating MySQL views?

WBOY
Release: 2023-09-09 10:09:11
forward
587 people have browsed it

在创建 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)
Copy after login

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!

source:tutorialspoint.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template