I have two tables
table A
---------
uid c1(distinct)
---------
1 a
1 b
2 c
3 d
3 e
3 f
4 g
and
table B
---------
uid c2(non unique)
---------
1 x
2 y
3 z
3 z
3 v
I need a resultant table which maps table A to table B on uid like this
Result Table
-------------
uid c1 c2
-------------
1 a x
1 b -
2 c y
3 d z
3 e z
3 f v
4 g -
Basically once a row from table B is used in the resultant table, it must be exhausted. None of the JOINS work in this case.
Both these tables contain large number of records, so I can't write individual queries for each uid.