Reputation: 728
I have this query :
$query = mysql_query ("SELECT *
FROM saledb.application
WHERE app_id = (
SELECT app_id
FROM saledb.applicationdetails
WHERE is_hot = '1'
) LIMIT $Kvet,$Zet
");
And I have the following error:
Unable to save result set in /home/lemondo/lemondosales.itnovations.ge/content/tpl/gtpl/main.php on line 68
When I changing select item with MAX(app_id) it works but i need show all results. i know where is problem mysql cant choose in one query meny ID but i need alternativ query.
Upvotes: 2
Views: 233
Reputation: 132
$query = mysql_query ("SELECT * FROM saledb.application WHERE app_id IN (SELECT app_id FROM saledb.applicationdetails WHERE is_hot = '1') LIMIT $Kvet,$Zet");
That should do the trick. If you leave '=' and the subquery returns more than one row, you wil get that error. To match all the lines in saledb.application that have the app_id in the result set you need to use "IN" :)
Upvotes: 0
Reputation: 79929
Use the IN
predicate instead of =
like os:
SELECT *
FROM saledb.application
WHERE app_id IN
(SELECT app_id
FROM saledb.applicationdetails
WHERE is_hot = '1');
Upvotes: 4