emediastudios Posted October 11, 2010 Share Posted October 11, 2010 Hi everyone. I am a newbie to mysql php and have a question. I can display records in a loop from one table but i want to display the records from another table as well that has the same quoteid and where approved is "n" This is what have so far, but there is also only 3 fields from the quotes table i want to display in the loop. $sql = mysql_query("SELECT * FROM comments WHERE approved LIKE 'n%'"); while ($row = mysql_fetch_array($sql)) { $count = mysql_num_rows ( $sql ); foreach($row as $key=>$value){ $$key = htmlentities(stripslashes($value)); } echo ' Hope i make sense. Quote Link to comment Share on other sites More sharing options...
pengu Posted October 11, 2010 Share Posted October 11, 2010 You need an inner join. $sql = mysql_query("SELECT c.field1,e.field2 FROM comments AS c INNER JOIN example AS e ON c.quoteid = e.quoteid WHERE c.approved LIKE 'n%'"); Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.