• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 414
  • 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

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

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