vl.pavlov wrote:
> here is example:
> 
> sqlite> create table tbl1(words text);
> sqlite> create table tbl2(words text);
> sqlite> insert into tbl2 (words) values ('seaside');
> 
> now i wish to insert into tbl1 some word, but if that word exist (eg
> seaside) in tbl2 to ignore (word should not be inserted)
> 
> 

This is what I thought you wanted. Using your table and column names my 
previous suggestion becomes:

   insert into tbl1
   select 'seaside'
   where not exists
     (select words from tbl2 where words = 'seaside')

The subselect will determine if the word is in tbl2 or not. If the word 
exists in tbl2, the subselect will return a row, so the where condition 
(not exists) on the select will be false, and the word will not be 
inserted into table tbl1. If the word doesn't exist in tbl2, the where 
condition will be true, and the word will be inserted into table tbl1.

HTH
Dennis Cote

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

Reply via email to