When using SELECT can you modify the value of a returned field based on other fields?
Posted
by
user570759
on Stack Overflow
See other posts from Stack Overflow
or by user570759
Published on 2011-01-15T18:45:31Z
Indexed on
2011/01/15
18:53 UTC
Read the original article
Hit count: 148
mysql-select
When using MySQL SELECT can you change the value of a returned field based on other fields?
For example, if I have this select:
SELECT city,state,country FROM table
Now if city is empty AND state is empty, I want the value of country to returned empty as well (whether country actually has a value or not).
Example table:
id | city | state | country
-----------------------------
1 | Here | There | MyCountry
2 | | | YourCountry
So with the above table, I want the results for id=1 to return Here,There,MyCountry but the results for id=2 should be empty,empty,empty
Thanks
© Stack Overflow or respective owner