Posts Tagged ‘MySQL’
Table joins in MySQL with no matches
I 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.
