I have a table with boolean values โโ(only 0 and 1) that should be CSV-ed for the client. I know that I can do 1 replace as follows:
SELECT REPLACE(email, '%40', '@'), REPLACE(name,'%20', ' '), REPLACE(icon_clicked, 1, 'Yes') FROM myTable WHERE id > 1000;
This converts all the values โโof 1 to "Yes", but how to do it in one query for 1 => Yes and 0 => No, so the logical result is stored in one column? I tried to do this:
SELECT REPLACE(email, '%40', '@'), REPLACE(name,'%20', ' '), REPLACE(icon_clicked, 1, 'Yes'), REPLACE(icon_clicked, 0, 'No') FROM myTable WHERE id > 1000;
But this query created an additional column to replace the row โNoโ (so the final result consisted of 4 columns, email, name, icon_clicked-> yes, icon_clicked-> no)
source share