nuclearmaker
nuclearmaker

Reputation: 119

mysql null to 0

SELECT * from book;

how to convert NULL result to 0 from the sql ?

Upvotes: 7

Views: 2156

Answers (2)

Danny T.
Danny T.

Reputation: 1140

You're looking for the COALESCE keyword:

SELECT COALESCE(fieldName, 0) FROM book

Upvotes: 17

Peter Lang
Peter Lang

Reputation: 55524

SELECT IFNULL(pages, 0) FROM book;

if pages was the name of your column.

Upvotes: 6

Related Questions