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. Quote 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 Quote 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
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.