0

I have a table that has the following columns: year, city, country, avg_temp.

I am trying to write a query that extracts the data into a CSV, but I want the fields with no input to show NULL for avg_temp.

1
  • SELECT IF(columnName IS NULL, 'NULL', columnName) as columnName FROM table Commented Nov 28, 2020 at 19:06

1 Answer 1

0

You can check in the select with

CASE WHEN avg_temp IS NULL THEN 'NULL' ELSE avg_temp END AS avg_temp

Or with if

IF (avg_temp IS NULL, 'NULL', avg_temp) AS avg_temp
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.