Mukesh Kumar
Mukesh Kumar

Reputation: 33

How to get data from two different table with different columns

table1

id  | pid   |pdate

1   |ab001  |25/05/2017

2   |ab002  |25/05/2017

table2

id  |rid    |rdate

1   |cd001  |25/05/2017

2   |cd002  |25/05/2017

Output

id  |cid    |date

1   |ab001  |25/05/2017

2   |ab002  |25/05/2017

1   |cd001  |25/05/2017

2   |cd002  |25/05/2017 

Upvotes: 0

Views: 24

Answers (2)

RaMeSh
RaMeSh

Reputation: 3424

Try this example:

SELECT id FROM table1 UNION SELECT cid FROM table2;

Output:

id rid

1 ac22

Upvotes: 0

Timur
Timur

Reputation: 498

(SELECT table1.id, table1.pid, table1.pdate FROM table1)
UNION
(SELECT table2.id, table2.rid, table2.rdate FROM table2);

Upvotes: 1

Related Questions