Liad Livne
Liad Livne

Reputation: 63

How to overcome the error on join union tables with other table

While we try to join between union tables on one side with other table on the other side,

SELECT A.x,B.y FROM ([DataSet.Liad],[DataSet.Livne]) AS A INNER JOIN [DataSet.Names] AS B ON A.ID = B.ID LIMIT 10

we get this error:

Error: 2.1 - 0.0: JOIN cannot be applied directly to a table union or to a table wildcard function. Consider wrapping the table union or table wildcard function in a subquery (e.g., SELECT *).

In order to solve this error I suggest you to use a View. Save this Query of union as a View, DataSet.LiadLivne:

SELECT * FROM [DataSet.Liad],[DataSet.Livne] 

Execute the origin query using the view:

SELECT A.x,B.y FROM [DataSet.LiadLivne] AS A INNER JOIN [DataSet.Names] AS B ON A.ID = B.ID LIMIT 10

Enjoy

Upvotes: 4

Views: 2373

Answers (1)

Pentium10
Pentium10

Reputation: 207912

You need to write as:

SELECT A.x,
       B.y
FROM
  (SELECT A.x
   FROM ([DataSet.Liad],[DataSet.Livne])) AS A
INNER JOIN [DataSet.Names] AS B ON A.ID = B.ID LIMIT 10

Upvotes: 4

Related Questions