Sreejith A
Sreejith A

Reputation: 27

Fetch Recods from both tables

I have 2 table T1& T2 where fields and records are same.I need to fetch data on where condition from both tables.

For eg:-If data exists in both tables fetch common records meeting where condition.

If data exists in T1 not in T2 then fetch from T1 Vice versa also.

Upvotes: 0

Views: 14

Answers (1)

Tim Biegeleisen
Tim Biegeleisen

Reputation: 522516

Use a UNION:

SELECT * FROM T1 WHERE <some condition>
UNION ALL
SELECT * FROM T2 WHERE <some condition>

Upvotes: 1

Related Questions