KingOfHeart Posted December 14, 2008 Share Posted December 14, 2008 I have not used this function much so I don't understand how to use it completely. How can I show the data of both tables with just one search. Here is my current script $sql = "SELECT w.pageid, w.WDuserid, w.timedate, w.data FROM Wiki_Data w, Wiki_Main m Where w.pageid = m.id"; $result=mysql_query($sql); if(mysql_num_rows($result) == 0) { return false;//should not even run } $rows = mysql_fetch_array($result); $context['index_body'] = $rows['m.id'] . "<br>"; $context['index_body'] .= $rows['m.pagename'] . "<br>"; $context['index_body'] .= $rows['w.WDuserid'] . "<br>"; $context['index_body'] .= $rows['w.timedate'] . "<br>"; $context['index_body'] .= $rows['w.data'] . "<br>"; Even though it can display some of the names by removing the w. I don't want to have it set up like this. I made things easier by giving all my needed fields a different name, but I want a script that will work even if the two tables had the same field names. $context['index_body'] < this is just for showing the data. In the guide it says I have to list my MYSQL version, but not even sure how to find this out. Link to comment https://forums.phpfreaks.com/topic/136901-mysql-selecting-data-from-multi-tables/ Share on other sites More sharing options...
laPistola Posted December 14, 2008 Share Posted December 14, 2008 "SELECT w.pageid, w.WDuserid, w.timedate, w.data, m.columnName FROM Wiki_Data as w, Wiki_Main as m WHERE w.pageid = m.id"; change columnName to the names you use in that table Link to comment https://forums.phpfreaks.com/topic/136901-mysql-selecting-data-from-multi-tables/#findComment-715352 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.