To differentiate between "put no data" and "put empty data", you can use NULL.
Another differences are as follows:
- The LENGTH of an empty string is 0 and a LENGTH of NULL is NULL,
- NULLs will be sorted before the empty strings.
- COUNT(message) can count empty strings but not NULLs.
- By using a bound variable, you can search for an empty string but not for a NULL.
Query:
SELECT *
FROM mytable
WHERE mytext = ?
In above query, whatever value you pass from the client it will never match a NULL in mytext, .
To match NULLs, use below Query:
SELECT *
FROM mytable
WHERE mytext IS NULL