13.6.2 ALL子查询
ALL关键字表示如果同时满足所有子查询的条件,则返回TRUE,否则返回FALSE。
例如,查询t_goods数据表中t_category_id字段值大于t_goods_category数据表中所有id字段值的数据。
mysql> SELECT id, t_category_id, t_category, t_name, t_price
-> FROM t_goods
-> WHERE t_category_id > ALL (SELECT id FROM t_goods_category);
+----+---------------+----------------+------------+---------+
| id | t_category_id | t_category | t_name | t_price |
+----+---------------+----------------+------------+---------+
| 13 | 5 | 水果 | 葡萄 | 49.90 |
| 14 | 5 | 水果 | 香蕉 | 39.90 |
+----+---------------+----------------+------------+---------+
2 rows in set (0.00 sec)