Bug #23807 New Function, Empty()
Submitted: 31 Oct 2006 15:40 Modified: 1 Nov 2006 13:10
Reporter: Charlie Farrow Email Updates:
Status: Won't fix Impact on me:
None 
Category:MySQL Server Severity:S4 (Feature request)
Version:5.0 OS:Windows (XP SP2)
Assigned to: CPU Architecture:Any

[31 Oct 2006 15:40] Charlie Farrow
Description:
Please could we have a function that is the equivilent of the PHP function EMPTY.

You can find more details on the PHP empty syntax at:

http://www.php.net/empty

I think this would be really useful because sometimes you need to know if something is empty rather than just if it is Null.

Charlie

How to repeat:
NA

Suggested fix:
NA
[1 Nov 2006 13:10] Valeriy Kravchuk
Thank you for a feature request. I think, some combination of LENGTH and IFNULL will do the job:

mysql> select ifnull('', 1), length('');
+---------------+------------+
| ifnull('', 1) | length('') |
+---------------+------------+
|               |          0 |
+---------------+------------+
1 row in set (0.00 sec)

mysql> select ifnull(NULL, 1), length(NULL);
+-----------------+--------------+
| ifnull(NULL, 1) | length(NULL) |
+-----------------+--------------+
|               1 |         NULL |
+-----------------+--------------+
1 row in set (0.00 sec)

So, I see no need for a separate EMPTY() function, sorry.