Thanks alot RSmith.
On Mon, Nov 18, 2013 at 6:04 PM, d b <va230...@gmail.com> wrote: > Hi Igor/Keith, > > I tried with both queries. I expect to delete all rows belongs to key 1. > But not deleted. Am I missing something while writing queries? > > delete from emp where key = 1 and (name='' or name='f'); > DELETE FROM emp WHERE key = 1 AND (name IS NULL OR name = 'f'); > > > > ------------------------------------------------------------------------------------------------------------- > > create table if not exists emp(key integer not null, name text not null , > personaldata text not null, unique(key, name)); > insert into emp (key, name, personaldata) values(1, 'a', 'z'); > insert into emp (key, name, personaldata) values(1, 'b', 'zz'); > insert into emp (key, name, personaldata) values(2, 'c', 'y'); > insert into emp (key, name, personaldata) values(3, 'd', 'yy'); > insert into emp (key, name, personaldata) values(1, 'e', 'yyy'); > > -------------------------------------------------------------------------------------------------------------- > > > On Mon, Nov 18, 2013 at 5:20 PM, d b <va230...@gmail.com> wrote: > >> Thanks RSmith. >> >> It works. >> >> But, I am looking for single query for prepared statements. That's the >> actual struggle for me. >> >> >> On Mon, Nov 18, 2013 at 4:24 PM, d b <va230...@gmail.com> wrote: >> >>> Hi RSmith, >>> >>> Thanks. Still, I could not delete with single query. >>> >>> >>> create table if not exists emp(key integer not null, name text not null >>> , personaldata text not null, unique(key, name)); >>> insert into emp (key, name, personaldata) values(1, 'a', 'z'); >>> insert into emp (key, name, personaldata) values(1, 'b', 'zz'); >>> insert into emp (key, name, personaldata) values(2, 'c', 'y'); >>> insert into emp (key, name, personaldata) values(3, 'd', 'yy'); >>> insert into emp (key, name, personaldata) values(1, 'e', 'yyy'); >>> >>> bool delete_emp(int key, string name = "") >>> { >>> string query = ???; >>> >>> if(name.length() > 0) >>> { >>> //needs to delete specific row. by unique key. >>> } >>> else >>> { >>> //needs to delete rows belongs to key >>> } >>> } >>> >>> >>> On Mon, Nov 18, 2013 at 2:13 PM, d b <va230...@gmail.com> wrote: >>> >>>> Hi Luis, >>>> >>>> Those are parameters. >>>> >>>> This is the query after replacing with ?1 and ?2. >>>> >>>> delete from emp where key = '123' and (case when name = 'abc' is null >>>> THEN 1 else name = 'abc' end); >>>> >>>> It covered "delete from emp where key = '123' and name = 'abc';" but >>>> not other query. >>>> >>>> I tried with "select (case when name = 'abc' is null THEN 1 else name >>>> = 'abc' end) from emp;" query. It's always going to else portion when >>>> 'abc' doesn't exist in table. Any suggestions? >>>> >>> >>> >> > _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users