How can we use a combination of logical operators while creating MySQL views?

MySQLMySQLi Database

MySQL views can be created by using a combination of logical operators like AND, OR and NOT. It can be illustrated with the help of following examples:

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)
raja
Published on 22-Feb-2018 15:27:24
Advertisements