Syntax\n------\n\nSELECT ... WHERE EXISTS <Table subquery>\n\nDescription\n-----------\n\nSubqueries using the EXISTS keyword will return true if the subquery returns any rows. Conversely, subqueries using NOT EXISTS will return true only if the subquery returns no rows from the table.\n\nEXISTS subqueries ignore the columns specified by the SELECT of the subquery, since they're not relevant. For example,\n\n``sql\nSELECT col1 FROM t1 WHERE EXISTS (SELECT  FROM t2);\n`\n\nand\n\n`sql\nSELECT col1 FROM t1 WHERE EXISTS (SELECT col2 FROM t2);\n``\n\nproduce identical results.\n\nExamples\n--------\n\nCREATE TABLE sq1 (num TINYINT);\n\nCREATE TABLE sq2 (num2 TINYINT);\n\nINSERT INTO sq1 VALUES(100);\n\nINSERT INTO sq2 VALUES(40),(50),(60);\n\nSELECT  FROM sq1 WHERE EXISTS (SELECT  FROM sq2 WHERE num2>50);\n+------+\n| num  |\n+------+\n|  100 |\n+------+\n\nSELECT  FROM sq1 WHERE NOT EXISTS (SELECT * FROM sq2 GROUP BY num2 HAVING MIN(num2)=40);\nEmpty set (0.00 sec)\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/data-manipulation/selecting-data/joins-subqueries/subqueries/subqueries-and-exists