0
How to select a column referenced by a primary key from two databases in the same server?
I would like to select the projects column from clients database with a primary key of project id and I would like to join it with projects database. But I dont know what is the right query.
7 odpowiedzi
+ 3
Oh, sorry then :D
you can access any database, but you need to know in what schema they belong. So let's say clients database belongs to clients schema. To access table from there, you need to write full name like this: clients.table_name
+ 3
The second option :)
+ 2
Thank you!
+ 1
When joining two different tables, one table has to have a foreign key that references other table's primary key. And when you write select query, you join them on condition, where first table's foreign key is equal to second table's primary key
I don't know the correct syntax how to join two tables in MySQL, but you can look it up in their documentation page
+ 1
So would it be like SELECT clients_db.project_tbl.project_id, projects_db.project_details_tbl.project.id FROM clients_db, projects_db? :D is it right??
+ 1
Or would it be FROM clients_db.project_tbl, projects_db.project_details_tbl? :D
0
I actually want to join two different databases 😅