If you can build your SQL string with column_name exactly what is the problem 
with adding it a 2nd time?



How do you build your SQL statement?



And I get the same answer with either of your queries in 3.7.4 -- what version 
are you running and what answer are you getting?

Are you saying that "1" below doesn't show up in the first query result?



sqlite> create table t(i int,name string);
sqlite> insert into t values(1,NULL);
sqlite> insert into t values(2,'two');
sqlite> select * from t where i in (1,2,3,null);
i|name
1|
2|two
sqlite> select * from t where i in (1,2,3) or column_name is NULL;
Error: no such column: column_name
sqlite> select * from t where i in (1,2,3) or i is NULL;
i|name
1|
2|two



Michael D. Black

Senior Scientist

NG Information Systems

Advanced Analytics Directorate



________________________________
From: sqlite-users-boun...@sqlite.org [sqlite-users-boun...@sqlite.org] on 
behalf of yogibabu [madra...@interia.pl]
Sent: Saturday, July 02, 2011 3:21 AM
To: sqlite-users@sqlite.org
Subject: EXT :[sqlite] How to search for multiple values in a column including 
null without repeating column name ?


consider this:
  SELECT * FROM table_name WHERE column_name in(1,2,3) or column_name is
NULL

Here column name is referenced two times.
Putting it this way:
    SELECT * FROM table_name WHERE column_name in(1,2,3,null)
causes that in() ignores null value without giving any error.

I need to add last part of this query to a function that must be column_name
agnostic, so that is a reason that otherwise simple workaround is out of
question here.
--
View this message in context: 
http://old.nabble.com/How-to-search-for-multiple-values-in-a-column-including-null-without-repeating-column-name---tp31978469p31978469.html
Sent from the SQLite mailing list archive at Nabble.com.

_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to