IF ( ) Function
SELECT DVDName AS Title, StatID AS Status, RatingID AS Rating,
IF (NumDisks>1, ‘Check for extra disks!’, ‘Only 1 disk.’) AS Verify
FROM DVDs
ORDER BY Title;
The IFNULL ( ) function returns a value based on whether a specified expression evaluates to NULL.
The NULLIF() function is a little different from the IFNULL() function. The NULLIF() function returns NULL if <expression1> equals <expression2>; otherwise, it returns <expression1>.
SELECT NULLIF(10*20, 20*10);
As you can see, the statement specifies two expressions. Because they are equal (they both return a value of 200), NULL is returned, rather than the value of 200 returned by the first expression.
No comments:
Post a Comment