I have two databases on the same server.
I want to show single result from two different databases when user search any term! how can we do this? I am using JSP
I have two databases on the same server.
I want to show single result from two different databases when user search any term! how can we do this? I am using JSP
You don't need to connect with both databases. Let me explain..
We have two databases DB_1 and DB_2, both has tables DB_1.Table1 and DB_2.Table2.
Assuming that DB_1 has more tables to use in. Here you just need to provide GRANT on Table2 of DB_2 to DB_1. OR You may provide grant for all tables of DB_2 (as per you need). This is the way Oracle behave. If your DB server do not support the same just give the permissions (GRANT) to your DB_1's user to use multiple tables of different database.
and the query will look like..
Select t1.id, t1.name,t2.id, t2.name t2 from DB_1.Table1 t1, DB_2.Table2 t2 where...
And as you wrote
I want to show single result from two different databases when user search any term!
your query will be..
Select t1.id, t1.name from DB_1.Table1 t1 where...
Union All
Select t2.id, t2.name from DB_2.Table2 t2 where...