How to define a query joining tables in two different databases

128 Views Asked by At

I know how to write SQL to join tables in two databases but is there a way to do this in SQLyog.

This type of query gives a permissions error in that application.

SELECT 
   DB1.table1.col1, 
   DB2.table2.col2
FROM DB1.table1 
JOIN DB2.table2
ON DB1.table1.commoncol1 = DB2.table2.commoncol2

Additional info

If I have open the tab for one database and run a query for another database (also open in its own tab) ie

SELECT * FROM [email protected]

where [email protected] is the connection

databasename is the database name

tablename is the table name

then I get the error

Error Code: 1064
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '@51.195.123.67.databasename.tablename' at line 1

Back ticks don't help and I get the same problem if I leave out the connection altogether (as I would expect)

1

There are 1 best solutions below

1
Venkatakrishnan R On

do you think is that something do with running the application in sudo mode , so the problem of perimission would take place