I'm developing a MYSQL Stored Proc, and in that I need to validate a date field as follows,
IF (dt_wedding_date<>'') THEN
IF (int_days_to_wedding>0) THEN
SET vc_wedding ='F';
ELSE
SET vc_wedding ='P';
END IF;
ELSE
SET vc_wedding = 'NA';
END IF;
But when the dt_wedding_date is null it never goes to the ELSE part. I tried "is null", "is not null", ">", <>, trim functions, nothing worked.
Any idea how to evaluate this date field for nulls/empty?
try isnull function, I tried it on my local mysql
mysql> select * from data_test;
+----+------------+
| id | gmt_create |
+----+------------+
| 1 | NULL |
+----+------------+
1 row in set (0.00 sec)
mysql> select id, isnull(gmt_create) from data_test;
+----+--------------------+
| id | isnull(gmt_create) |
+----+--------------------+
| 1 | 1 |
+----+--------------------+
1 row in set (0.00 sec)
mysql>
from the w3c reference
MySQL does have an ISNULL() function. However, it works a little bit different from Microsoft's ISNULL() function.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.