Jump to content

select from multiple tables


mattm1712
 Share

Recommended Posts

hi im trying to echo out all the possibilities from one column in 2 different tables, both with the same structure. if that makes sense

 

this is what i have

 

$query = mysql_query("SELECT * FROM stanjamesprem,centrebetprem GROUP BY eventname ORDER BY eventtime ");

while($row = mysql_fetch_assoc($query))

{

echo $row[eventname];

}

 

if i take one of the tables out it works fine but if i have 2 table names it doenst work

 

please help me

 

cheers matt

 

any questions please ask away

 

Link to comment
Share on other sites

When you have a SELECT and a FROM you need to have a WHERE or you're just going to get everything in the world. The WHERE is the device that tells you the row or rows that you want to look at.

 

The GROUP BY is not needed.

 

After you get your query working you might need a ORDER BY but wait on that.

 

EDIT

PS:

You really shouldn't use the * but should name the columns you want to see. When you do that you need to have the table name plus a dot plus the column from that table. like

SELECT stanjamesprem.column, centrebetprem.whatelse FROM stanjamesprem, centrebetprem WHERE stanjamesprem.ID = centrebetprem.anotherID;

 

It's hard to give advise when i don't know what your trying to do.

Link to comment
Share on other sites

This thread is more than a year old.

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.

 Share

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