Reputation: 1436
I have two table which I need to join
Table1
col1 col2 col3
------------------
1 A 20
2 B 10
3 C 30
4 D 40
Table2
col1 col2
-----------
1 A
2 B
3 C
4 D
I have to make UNION of both table. As table2 doesn't have col3 I have added as dummmy column in query.
I need to perform search operation in both the table for col3
I tried but it throwing unknown column exception.
(SELECT col1, col2, col3 from table1 where col3 = "10")
UNION
(SELECT col1, col2, "10" as col3 from table2 where col3 = "10")
Any help would be appreciated
Upvotes: 0
Views: 180
Reputation: 125718
You can query the UNIONed data directly afterward:
SELECT col1, col2, col3 from
(
(SELECT col1, col2, col3 from table1)
UNION
(SELECT col1, col2, "10" as col3 from table2)
) as b
where col3 = "10"
Upvotes: 1