Jump to content

MYSQL selecting data from multi tables


KingOfHeart

Recommended Posts

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.