On 6/1/06, Kareem Badr <[EMAIL PROTECTED]> wrote:
I read the section on the SQLite website regarding the inconsistencies
of how NULL values are handled in various databases. I didn't see
anything that mentioned what I am running into, though.
In a nutshell, the following queries do not return rows when test_field
is NULL. It seems counter-intuitive to me.
SELECT * FROM my_table WHERE test_field NOT LIKE 'test value%'
SELECT * FROM my_table WHERE test_field != 'test value'
NULL is "nothing was ever entered into this column"
Which is different from an "Empty string" was entered into this column.
A user might legitimately want a field left blank,
which is different from the case where they never entered anything for
that field.
Is there an easy way around this, other than adding "OR test_field IS
NULL" to my queries? The example above is a lot simpler than the case I
need to handle in production, so I would like to avoid having to modify
every query to handle NULL values in a special case.
No, except you could set a default value of the empty
string for that column. If no value is specified, then the default is used,
and you won't get NULLs.
--
SqliteImporter, SqliteReplicator: Command line utilities for Sqlite
http://www.reddawn.net/~jsprenkl/Sqlite