php - Change a column name on select -
i have temporary table.
col_1 col_2 col_3 col_4 abc b01 10 5 abc b01 77 5 abc b03 30 7 abc b05 50 11 abc b05 88 11 def b05 50 50 def b05 88 50 def b06 66 50 a01 b02 20 0 a01 b04 40 0 a02 b02 99 0
and helper table:
id1 id2 abc a01 def a02
what i'd do. if there values in col_1 in temporary table matches id2 in helper table, values changed id1 in helper table. how on select
?
so, when select (select * temporary
). result:
col_1 col_2 col_3 col_4 abc b01 10 5 abc b01 77 5 abc b03 30 7 abc b05 50 11 abc b05 88 11 def b05 50 50 def b05 88 50 def b06 66 50 abc b02 20 0 abc b04 40 0 def b02 99 0
is possible that? help
nb:
there lot of values in helper table. not 2 rows.
left join case
select case when h.id2 = tt.col_1 h.id1 else tt.col_1 end col_1, col_2,col_3,col_4 temporary_table tt left join helper h on tt.col_1 = h.id2
Comments
Post a Comment