PDA

View Full Version : Need help with a query


Michael Morris
02-10-2005, 07:09 PM
Here it is

SELECT * FROM post
WHERE userid = 1
AND postid IN SELECT reviewids from product where productid = 3

The product table has a field called reviewids which is a list of reviewsids in this format 980,1020,2212

I know I can execute a single query to grab the ids and a second query to make this check (which should return true or false), but I'd rather do it in one query if I can.

Dean C
02-10-2005, 08:50 PM
Nothing wrong with a subquery if you can do it :)

sabret00the
02-10-2005, 09:18 PM
wouldn't he need to explode and FIND_IN_SET the original listed data if it's in the format of 454,5656,34232,134?

Dean C
02-11-2005, 07:43 AM
If he's using MySQL4 then he can use subqueries :) Personally for scalability I'd get a list of ID's, and then use WHERE productid IN($ids)

Michael Morris
02-11-2005, 03:35 PM
Ah.. Well, I'm not using 4+. I broke it in half pretty much as you described Dean. Thx.