i have 2 tables similar columns. say,
table x
has id,first_name last_name
.
table y
has id,email_id, first_name
.
however both these tables imperfect, need fill in null values in both tables data in other table(using key(id in eg)) , push table.
how can efficiently ?
just join tables , write case
statement.
example 0:
select x.id id , case when x.first_name null y.first_name else x.first_name end first_name , x.last_name last_name , y.email_id email_id db.tablex x join db.tabley y on y.id = x.id
or pretty same if
statement.
example 1:
select x.id id , if(x.first_name null, y.first_name, x.first_name) first_name , x.last_name last_name , y.email_id email_id db.tablex x join db.tabley y on y.id = x.id
Comments
Post a Comment