Click to See Complete Forum and Search --> : select problems
prt20
06-08-2008, 12:16 PM
i have many tables in one DB and want to search all the tables and return all from where a specific ID is found, however many of the tables have different columns and using a simple wont work.....
Select * from DB
where id= 1
any ideas?
chazzy
06-08-2008, 04:13 PM
you need to just select stuff from the tables separately. this sounds like it could be dangerous (imagine if you keep hash keys in a DB)
NogDog
06-08-2008, 04:14 PM
You could use a UNION:
SELECT * FROM table1 WHERE id=1
UNION SELECT * FROM table2 WHERE id=1
UNION SELECT * FROM table3 WHERE id=1
UNION SELECT * FROM table4 WHERE id=1
chazzy
06-08-2008, 04:19 PM
union won't work in this case, we already know all of the tables have different structure.
prt20
06-09-2008, 04:53 AM
how could it work with JOIN ? if it would work at all?????