andros_k Posted June 18, 2009 Share Posted June 18, 2009 Hello, can i use mysql_fetch_array for one sql selection and retrieve data from 2 or 3 tables? Thanx! Link to comment https://forums.phpfreaks.com/topic/162776-mysql_fetch_array-from-multiple-table/ Share on other sites More sharing options...
radalin Posted June 18, 2009 Share Posted June 18, 2009 If you write a query like: $sql = "SELECT a.id, a.name, b.id, b.surname FROM table1 a, table2 b WHERE b.id = a.id"; $res = mysql_query($sql); //Validate the $res while ($row = mysql_fetch_array($res)) { var_dump($row) } It will work. The problem is on writing the right query with right joins. Link to comment https://forums.phpfreaks.com/topic/162776-mysql_fetch_array-from-multiple-table/#findComment-858981 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.