[RESOLVED] Select from 2 tables
I have 2 tables: lss1 & lss2 and the content needs to be selected from either table depending on the criteria.
I am getting the following error: "Couldn't execute query: Column 'id' in where clause is ambiguous"
$sql="SELECT * FROM lss1, lss2 WHERE id=$variable";
How do I not make the "id" ambiguous when it could go to either table?
specify id from which table to select. i think you need...
$sql="SELECT * FROM lss1, lss2 WHERE lss1.id=$variable and lss1.id=lss2.id";
If the two tables are truly separate (as opposed to joined on a common field), then you may need to do a union
Note that you must select the same number/type of columns from each table.
select col1, col2, col3 from table1 where something='something'
select col2, col2, col3 from table2 where something='something'
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)