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


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)

Updated on: 22-Jun-2020

112 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements