为了将行选择与列选择结合起来,我们可以使用“WHERE”子句。例如,我们有下面的表格 -
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)
现在,以下查询将展示如何使用 WHERE 子句将行选择与列选择结合起来。
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)