Page 1 of 1

Breaking up a nested query

Posted: Sun Jan 21, 2007 8:20 pm
by jimmyp3016
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?

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";
Any help would be great thanks!

Posted: Sun Jan 21, 2007 8:50 pm
by aaronhall
Have you tried joining the tables?

Posted: Mon Jan 22, 2007 8:59 am
by feyd
SQL question :arrow: Databases.