Programming Tutorials

(追記) (追記ここまで)

sql if null then 0

By: Mary in MySQL Tutorials on 2023年05月02日 [フレーム]

In SQL, you can use the IS NULL condition to check if a value is NULL. To return 0 when the value is NULL, you can use the COALESCE function or the IFNULL function, depending on the database system you are using.

Here's an example using the COALESCE function:

SELECT COALESCE(column_name, 0) FROM table_name;

This will return the value of column_name, or 0 if column_name is NULL.

Here's an example using the IFNULL function (this is specific to MySQL and SQLite):

SELECT IFNULL(column_name, 0) FROM table_name;

This will return the value of column_name, or 0 if column_name is NULL.




(追記) (追記ここまで)


Add Comment

JavaScript must be enabled for certain features to work
* Required information
1000

Comments

No comments yet. Be the first!

Most Viewed Articles (in MySQL )

Latest Articles (in MySQL)

(追記) (追記ここまで)
(追記) (追記ここまで)

Related Tutorials

AltStyle によって変換されたページ (->オリジナル) /