Row Subqueries
Retrieve a single row of multiple values. A row subquery returns a tuple that can be compared against a row constructor in the outer query.
Examples
CREATE TABLE staff (name VARCHAR(10), age TINYINT);
CREATE TABLE customer (name VARCHAR(10), age TINYINT);
INSERT INTO staff VALUES ('Bilhah',37), ('Valerius',61), ('Maia',25);
INSERT INTO customer VALUES ('Thanasis',48), ('Valerius',61), ('Brion',51);
SELECT * FROM staff WHERE (name,age) = (SELECT name,age FROM customer WHERE name='Valerius');
+----------+------+
| name | age |
+----------+------+
| Valerius | 61 |
+----------+------+SELECT name,age FROM staff WHERE (name,age) IN (SELECT name,age FROM customer);
+----------+------+
| name | age |
+----------+------+
| Valerius | 61 |
+----------+------+Last updated
Was this helpful?

