How can we combine ROW selection with COLUMN selection in MySQL?

MySQLMySQLi Database

For combining ROW selection with COLUMN selection, we can use the ‘WHERE’ clause. For example, we have a table below −

mysql> Select * from Student;
+--------+--------+--------+
| Name   | RollNo | Grade  |
+--------+--------+--------+
| Gaurav | 100    | B.tech |
| Aarav  | 150    | M.SC   |
| Aryan  | 165    | M.tech |
+--------+--------+--------+
3 rows in set (0.00 sec)

Now, the following query will show how we can combine ROW selection with COLUMN selection using WHERE clause.

mysql> Select Name, RollNo, Grade from Student where Grade='M.Sc' or Grade='B.Tech';
+--------+--------+--------+
| Name   | RollNo | Grade  |
+--------+--------+--------+
| Gaurav | 100    | B.tech |
| Aarav  | 150    | M.SC   |
+--------+--------+--------+
2 rows in set (0.00 sec)
raja
Published on 21-Feb-2018 12:51:47
Advertisements