Is there a way I can select multiple rows in MYSQL based on the IDs saved in another row of another table?

You can do it in one query: SELECT p. * FROM outfits AS o INNER JOIN products AS p ON p. Pid IN (o.

Tid, o. Did) This has the additional benefit that you're not blindly pasting PHP values into your query (which is generally a big red flag, because unless you're really really careful, you're opening up a big box of SQL injection vulnerabilities).

1'ed - As long as outfits with no products do not need to be retrieved this is it. – stefgosselin Jun 19 at 9:42 If they do, use a LEFT JOIN instead. – tdammers Jun 19 at 10:00 This query shows a loop of all the product rows that have match in the outfit row, but what I wanted to do is to have a loop of outfits, and for each outfit there's a tid, and a did.

– Mohamed Said Jun 19 at 20:11 It may not be obvious, but my query does just that - only that the inner loop happens in the database engine, not in your code. Note that an inner join can return multiple rows for each matched row in either of the joined tables. If you want to group things by outfit rows, sort the query by outfit ID (or outfit name, or any other unique column in the outfit table), and make your loop check that; each time you hit a different outfit, print a sub-heading.

– tdammers Jun 190 at 9:39.

Try this $sqlstr2 = mysql_query("SELECT * FROM products WHERE pid in (select id from second table where condition )")or die(mysql_error()).

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions