Page 1 of 1

Simple table JOIN

Posted: Fri Jul 05, 2002 9:49 pm
by badre
Have tried every combination, and researched...no luck, just need to join two tables which have the same columns. The following works, but need to add/join the other table, it's for a calendar of events.

Other table: "hr_sub", uses the same WHERE, and ORDER BY...Thanbks if you can help, B.

$qr = mysql_query("SELECT * FROM cal_main WHERE LEFT(mdate, 6) = '".$tab."' ORDER BY mdate");

$nrows = mysql_num_rows($qr);
$rString = "n=".$nrows;

for ($i=0; $i < $nrows; $i++) {
$row = mysql_fetch_array($qr);
$rString .= "&mdate".$i."=".$row['mdate']."&title".$i."=".$row['title'];
$rString .= "&info".$i."=".$row['info']."&email".$i."=".$row['email'];
$rString .= "&url_ad".$i."=".$row['url_ad']."&caption".$i."=".$row['caption'];

Posted: Sat Jul 06, 2002 7:34 am
by Pekka
Have tried every combination, and researched...no luck, just need to join two tables which have the same columns.
If get your question right:

Code: Select all

SELECT table1.col1 , table2.col1, table3.col1
FROM table1, table2, table3
WHERE table1.col1 = table2.col1
AND table2.col1 = table3.col1
ORDER BY table1.col1

Posted: Sat Jul 06, 2002 8:13 am
by badre
Thanks for the reply...

Trying out what you sent me...in the meantime to clarify, I'm only matchiing up column names in the array, not any data, I want to combine the data , like take two tables and make one, and I can't quite get it. Thanks