That would 'splain it...I should have noticed...

So we're left with this question...



What's the problem with building the query that works?  I don't see where you 
can't make it "column agnostic"...though perhaps there's another definition of 
that....



sprintf(sql,"select * from t where %s in (1,2,3) or %s is NULL","i","i");



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 Jean-Christophe Deschamps [j...@antichoc.net]
Sent: Saturday, July 02, 2011 8:01 AM
To: General Discussion of SQLite Database
Subject: EXT :Re: [sqlite] How to search for multiple values in a column 
including null without repeating column name ?

Michael,

>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 i is NULL;
>i|name
>1|
>2|two

The query is more likely:
select * from t where name in ('two',null);
i|name
2|two

In your example there is no null in the i column.

--
<mailto:j...@q-e-d.org>j...@antichoc.net

_______________________________________________
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