A row subquery is a subquery returning a single row, as opposed to a scalar subquery, which returns a single column from a row, or a literal.
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 | +----------+------+
Finding all rows in one table also in another:
SELECT name,age FROM staff WHERE (name,age) IN (SELECT name,age FROM customer); +----------+------+ | name | age | +----------+------+ | Valerius | 61 | +----------+------+
© 2019 MariaDB
Licensed under the Creative Commons Attribution 3.0 Unported License and the GNU Free Documentation License.
https://mariadb.com/kb/en/subqueries-row-subqueries/