Hy. I'm trying to do a select from multiple databases and tables for an occurence.
let's say i have databases db1, db2 and db3. Each have the following tables t1, t2, t3. And in each table there is a field named id which i want to select and a field and p_id which i want to use as a condition. To give a better idea this is an example of what results i want to get:
---------------------------------------
|id_t1 | id_t2 | id_t3 | database_name|
---------------------------------------
| 100 | 123 | 356 | db1 |
| 252 | 156 | 566 | db2 |
|... | ... | ... | db3 |
---------------------------------------
How can i pass the p_id condition to each table and each database. I tried this: select t1.id as id_t1, t2.id as id_t2, t3.id as id_t3, (select database()) as database_name from db1.t1, db1.t2, db1.t3 where
****can't make the condition work because if i only say p_id = 100 it says it's ambiguous**** union select *** all the above *** from db2 and db3
I have also tried with join but it's not what i want (at least how i tried it) because there is no link between tables.
Thanks