Jörgen Hägglund
<jorgenhaggl...@netscape.net> wrote: 
> Hi all!
> I have three tables, one containing IP addresses as integers, lets
> call 
> it 'base'.
> A second table containing IP ranges and the country code the range
> belongs to. Lets call this 'IPtoCC' with the fields IPFrom and IPTo as
> integers and CC as text.
> Then a third, 'Exclude', containing country codes i want to be
> excluded with a single field CC as text.
> What I need is to delete all records in 'base' where base.IP falls
> into 
> a range of IPtoCC.IPFrom to IPtoCC.IPTo and that IPtoCC.CC is in
> Exclude.CC. Is it possible to do this in a single DELETE?

delete from base where exists
(select 1 from IPtoCC join Exclude on (IPtoCC.CC = Exclude.CC)
 where base.IP between IPFrom and IPTo);

Igor Tandetnik

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

Reply via email to