Converting subselects to MySQL Select all records from table1 where table1.column1 exists as table2.columnY on table2 with table2.columnX equal to value: SELECT * FROM table1 WHERE column1 IN ( SELECT columnY FROM table2 WHERE columnX = value )... express it like this in MySQLSELECT table1.* FROM table1, table2 WHERE table1.column1 = table2.columnY AND table2.columnX = valueSelect all record from table1 for which table1.column1 doesn't exist as table2.columnX: SELECT * FROM table1 WHERE column1 NOT EXISTS ( SELECT columnX FROM table2 )... express it like this in MySQLSELECT table1.* FROM table1 LEFT JOIN table2 ON table1.column1 = table2.columnX WHERE table2.columnX IS NULL(this only works for table2.columnX declared as NOT NULL)
Last update: Wed, 2 Nov 2005 10:16:21 GMT | top |