Writing SQL

Inserts, NULLs and Cleanup

Filling empty columns with INSERT and UPDATE, and handling NULLs and spaces with coalesce() and trim().

How to get 0 instead of NULL in SQL?

Replace NULL with 0 in SQL using COALESCE, IFNULL, ISNULL or NVL. Learn why storing 0 in place of NULL can change averages, counts and totals.

1 min read

What does trim() do in SQL?

TRIM() removes spaces from the start and end of text by default. See what it does, how it differs across databases, and how to clean empty-looking values.

1 min read

What is an insert statement?

An INSERT statement adds new rows to a table. Learn its syntax, how to insert several rows at once, and why it can't fill an empty column in existing rows.

1 min read

What is coalesce() in SQL?

COALESCE() returns the first value in a list that is not NULL. Learn how it works, with examples for filling empty columns in SQL tables and queries.

1 min read

Related topics

More in writing sql