如何在 MySQL 中组合行选择与列选择?
要组合行选择和列选择,我们可以使用“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)
广告