Scalar Subqueries
Return a single value. A scalar subquery produces a one-row, one-column result that can be used anywhere a constant or expression is valid.
Last updated
Was this helpful?
Was this helpful?
INSERT INTO sq1 VALUES (2);
INSERT INTO sq2 VALUES (10* (SELECT num FROM sq1));
ERROR 1242 (21000): Subquery returns more than 1 rowINSERT INTO sq2 VALUES (10* (SELECT num FROM sq3 WHERE num='3'));
SELECT * FROM sq2;
+------+
| num |
+------+
| 10 |
| NULL |
+------+SELECT * FROM sq1 WHERE num = (SELECT MAX(num)/10 FROM sq2);
+------+
| num |
+------+
| 1 |
+------+