Breaking up a nested query
Posted: Sun Jan 21, 2007 8:20 pm
Hey Guys,
I am running an older verison of sql on my webhost and it does not support nested querys which was enabled in 4.1 i think.
How can I break up this statement so my code will run on my server?
Any help would be great thanks!
I am running an older verison of sql on my webhost and it does not support nested querys which was enabled in 4.1 i think.
How can I break up this statement so my code will run on my server?
Code: Select all
$sql = "SELECT *, COUNT(id) AS referrals FROM user WHERE id IN (";
$sql .= " SELECT DISTINCT u.referral FROM user u, transaction t WHERE u.id=t.userID";
$sql .= ") GROUP BY id";