Oracle NVL equivalent in MySQL

Read – What is Oracle NVL

Many Oracle Developers who write code in MySQL will look for this solution.

Answer 1 :- IFNULL

Answer 2 :- COALESCE ( It returns first not null expression in the list)

IFNULL

mysql> select IFNULL(null,1);
will return 1

COALESCE

mysql> select COALESCE(null,1);
will return 1

Note:- COALESCE will work in Oracle too.

Advertisements

2 thoughts on “Oracle NVL equivalent in MySQL

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s