I have two tables,mycode and mycode1
The two tables contain same field CODE and img. I need to insert the table2 to table 1 two tables. Both of them contain the same code numbers in CODE field.
eg: table 1
CODE img
110 null
111 null
112 image3.jpg
table 2
CODE img
110 imag1.jpg
111 image2.jpg
I need the output as
table2
CODE img
110 imag1.jpg
111 image2.jpg
112 image3.jpg
vishnu sureshPosted Jan 15, 2015, 12:24 AM
select CODE, COALESCE(t1.img,t2.img) AS img
FROM newcode t1
INNER JOIN Mycode6 t2 ON t1.CODE= t2.CODE
Pradeep ShetPosted Jan 14, 2015, 11:40 AM
This can be done as below
SELECT CODE, COALESCE(t1.img,t2.img) AS img
FROM table1 t1
INNER JOIN table2 t2 ON t1.Code = t2.Code
This will give you the desired output. Mark it as answered if it helped you.