Thread: searching multiple tables and databases
I'm currently looking for the best way to search across multiple tables and databases. I'm not sure where to even start and what would be the best way to approach this. if someone could point me in the right direction it would be greatly appreciated.
Mike
>I'm currently looking for the best way to search across multiple tables and databases.You use a union query to join the results from multiple queries from different tables. For example:Employees Table1 Peter2 Paul3 MaryCustomers Table1 John2 Ringo3 PaulSELECT 'Employee' AS what, id, nameFROM EmployeesWHERE name ~* '^P'UNIONSELECT 'Customer' AS what, id, nameFROM CustomersWHERE name ~* '^P'ORDER BY name;Would return something like:Employee 2 PaulCustomer 3 PaulEmployee 1 PeterI can't tell you how you would do something like this accross multiple databases. There may be better ways...