Jump to content

select from multiple tables


mattm1712

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
https://forums.phpfreaks.com/topic/260084-select-from-multiple-tables/
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.

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.