mysql - Selecting column with opposite value of one given -
i have 2 columns column_a(int) , column_b(int). want select query gives me value in column not contain value give. example:
column_a| column_b 5 | 10 if select (something on here) table column_a = 10 or column_b = 10; result should push out 5 (value in column_a.
is possible?
note: value of 10 in either columns. lets if 10 in column_a , 5 in column_b, above query should still give me 5 retrieved column_b instead of column_a
note 2: both columns never contain same value.
in contrived example, use case statement attempt select value 2 columns not match:
select case when column_a = 10 column_b else column_a end yourtable column_a = 10 or column_b = 10 -- might optional
Comments
Post a Comment