Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there any difference b/w IS NULL in MySQL and MS SQL

What is the difference b/w IS NULL functions in MySQL and MS SQL.

(@VendorID IS NULL OR @VendorID = Contract.VendorID) this is the MS SQL statement.If I want this in MySql do I need to change the syntax.And one more thing is What is IF Null?

like image 712
Shree Avatar asked Feb 16 '23 12:02

Shree


1 Answers

You can use IS NULL in MySQL.

IFNULL is a function that will return another value if the field is NULL. This is SQL Servers equivalent of ISNULL

For example:

 IFNULL(VendorId, 0)

Will return 0 if the VendorId is null

You can also use COALESCE which will return the first non NULL value:

SELECT COALESCE(Field1, Field2, Field3)
FROM YourTable
like image 112
Darren Avatar answered Feb 18 '23 00:02

Darren