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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.