KrisWillis.com

Flower

Archive for the ‘MySQL’ Category

Table joins in MySQL with no matches

MySQL LogoI consider my understanding of MySQL around the intermediate level, but when writing table joins in the past I have always used the ‘equi-join’ method:

SELECT t1.*, t2.`name` FROM t1, t2 WHERE t1.n = t2.n;

Now, when a record for t2.n doesn’t exist, a row will not be returned. To solve this problem in the past, I would have executed two separate queries and process the output with PHP – Not the most efficient solution.

(more…)

You are currently browsing the archives for the MySQL category.