• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 415
  • Last Modified:

Substitute for an equi join.

When two tables have the same column, and one way to retrieve the
data is to put an equi join, Is there anyother way to retrieve results.
0
sakthikumar
Asked:
sakthikumar
2 Solutions
 
Rajkumar GsSoftware EngineerCommented:
If all the columns of the two tables are same, you can use UNION - which returns distinct records from two tables (If there are same records in both tables, it will return only once)
SELECT * FROM Table1
UNION
SELECT * FROM Table2

Open in new window


If you use UNION ALL, it will not filter duplicate rows. It will return all the records from two tables, even they are same
SELECT * FROM Table1
UNION ALL
SELECT * FROM Table2

Open in new window


Raj
0
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
can you please explain why you want to know such a "replacement"?
0
 
dqmqCommented:
There are many kinds of joins as well as unions that are capable of returning data from multiple tables (whether or not they "have the same column").  

It all depends on what you are trying to accomplish.  If you reveal that, perhaps one of us can be more forthcoming with assistance.
0
 
sakthikumarAuthor Commented:
I got those questions in one of an interview.
0
 
dqmqCommented:
They are probably "fishing" for the UNION answer.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now