[SOLVED] Join two mysql tables in php

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
moussa854
Forum Newbie
Posts: 23
Joined: Thu Apr 30, 2009 4:10 pm

[SOLVED] Join two mysql tables in php

Post by moussa854 »

Hi,
I have two tables 'tbl_name' & 'attending' in the same database 'csv_db'

I would like to join 'attending' to 'tbl_name' by name. My original code is:

Code: Select all

 $result = mysql_query('select * from (select * from tbl_name WHERE PLAN != "" AND PLAN != "HOME"  ORDER BY NAME DESC ) AS x GROUP BY NAME, PLAN'); 
I tried

Code: Select all

 $result = mysql_query('select * from (select tbl_name.NAME, tbl_name.PLAN, attending.Attending from tbl_name LEFT JOIN attending ON tbl_name.NAME =attending.NAME WHERE tbl_name.PLAN != "" AND tbl_name.PLAN != "HOME"  ORDER BY tbl_name.NAME DESC ) AS x GROUP BY tbl_name.NAME, tbl_name.PLAN');

while($row = mysql_fetch_array($result))
{
$body= $row['tbl_name.NAME'];
} 
but I get "Query was empty"
"SCREAM: Error suppression ignored for
Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in ..."

any idea

this is solved here
http://forums.devshed.com/mysql-help-4/ ... 16029.html
Post Reply