vijayvijay77 wrote: table3<!---join--->Slect table1.x, table2.y where databasename.dbo.table1.Coomon_field = databasename.dbo.table2.common_field |
Your syntax is a bit muddled there.
I would expect something like
SELECT
aTable.aField,
aTable.bField,
bTable.cField
FROM
aTable,
bTable
WHERE
aTable.common_field = bTable.common_field
OR
SELECT
aTable.aField,
aTable.bField,
bTable.cField
FROM
aTable INNER JOIN
bTable ON aTable.common_field = bTable.common_field
Your code was missing the FROM clause and you did not list what fields you wanted in the SELECT clause.
P.P.S
If you are trying to join two tables from two databases that can not (and can not be made to) see each other. You can do basically the same thing with Query of Query. You would just query the desired data from each database. Then you would use a query of query <CFQUERY>...</CFQUERY> block, substituting the variables with the other table's data in them for the table names in the SQL.
Just be awary that Query of Query has rather limited joining capability and can only do inner joins.