]> MySQL 5 🌐:aligrant.com


Alastair Grant | Tuesday 14 March 2006

Of course, there is a reason why I upgraded my MySQL installation on my Linux box (see below post). It was due to MySQL 5 being so much better than 4.1.

I found this out the hard way after getting PHP 5 to work with MySQL 4 and my SQL statements weren't working. I had no idea what I was doing wrong. I write SQL all day at work (albeit, Transact-SQL, but there isn't *that* much difference).

Turns out MySQL 4 doesn't do sub-queries! I can't believe this has never caused me a problem before! This is an example of a sub-query:

SELECT user_name 
FROM users 
WHERE user_id IN (
    SELECT user_id 
    FROM permissions 
    WHERE permission_description = 'administrator'

This query would get a list of all user's who had the "administrator" role set to them. Naturally this is a fictitious table, I'm not bleating out code that I use in my work! Although the concept is similar...

Breaking from the voyeuristic norms of the Internet, any comments can be made in private by contacting me.