Apache Awk Bash C cftp daemontools DHCP djbdns DNS Emacs Email ezmlm Fetchmail find GDB Hardware HTML HTTP Intro ISDN less Make Math mc mirrordir MySQL Peripherals Perl PHP3 pppd qmail Regexps Shell System Tables test To do Typical ucspi-tcp Versions Index TCP/IP slides
 

Rules of thumb for MySQL

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 MySQL
SELECT table1.* FROM table1, table2 WHERE table1.column1 = table2.columnY AND table2.columnX = value
Select 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 MySQL
SELECT 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