Post subject: query multiple tables and i think my statement is wrong
Posted: Fri Oct 10, 2008 8:42 pm
Joined: Fri Oct 10, 2008 8:40 pm Posts: 1
Hey all,
Ive been trying to put together a php page for the last couple weeks that does a query on multiple tables at 1 time, and returns the results from each. In other words, i put in a search, it searches all the tables, then returns the results from whatever tables it finds my data in. each table is extremely different from the other, and as is the data. Im pretty sure that its just my statement that is wrong. Here is my statement but I cant seem to get it working right. Any help would be greatly appreciated.
select 'table1' results from table1 where field1= '$var' or field2 = '$var'
union
select 'table2' results from table2 where field1 = '$var'
union
select 'table3' results from table3 where field1 = '$var'
Users browsing this forum: No registered users and 4 guests
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum