Re: [sqlite] One more SQL statement question

2009-09-09 Thread Dennis Volodomanov
> The not-in subselect could be expensive, depending on table size. If > it turns out to be expensive, you might consider reference counting. Thank you for the hint. It's done on an integer column with an index, so hopefully won't be too bad. Further tests will show though of course. Dennis

Re: [sqlite] One more SQL statement question

2009-09-09 Thread Jim Showalter
5:17 PM Subject: Re: [sqlite] One more SQL statement question >> sqlite> create trigger UpdateData after update on tablea begin >>...> delete from tableb where id=old.refb and id not in ( select >> refb from tablea ); > > Yep, that&

Re: [sqlite] One more SQL statement question

2009-09-09 Thread Dennis Volodomanov
> sqlite> create trigger UpdateData after update on tablea begin >...> delete from tableb where id=old.refb and id not in ( select > refb from tablea ); Yep, that's exactly what I need. Thank you! Dennis ___ sqlite-users mailing list sqlite-use

Re: [sqlite] One more SQL statement question

2009-09-09 Thread Simon Davies
2009/9/10 Dennis Volodomanov : > Hello, > > I have one more SQL query question - the people on this list have been very > helpful in the past, so thank you! > > I'm trying to create a trigger that would delete unreferenced rows from a > table. > > Let's say the schema is like this: > > TABLEA ( I

Re: [sqlite] One more SQL statement question

2009-09-09 Thread Dennis Volodomanov
> This statement makes no sense to me. Why not simply > > delete from TABLEB where ID=old.REFB and ID != new.REFB; But entries in TABLEB may be used by other entries in TABLEA and I don't want them deleted if they're used by at least one entry in TABLEA. Thanks, Dennis

Re: [sqlite] One more SQL statement question

2009-09-09 Thread Igor Tandetnik
Dennis Volodomanov wrote: > I'm trying to create a trigger that would delete unreferenced rows > from a table. > > Let's say the schema is like this: > > TABLEA ( ID INTEGER PRIMARY KEY, REFB INTEGER ); > TABLEB ( ID INTEGER PRIMARY KEY, DATA ); > > And let's say the data is like this: > > TABLEA:

[sqlite] One more SQL statement question

2009-09-09 Thread Dennis Volodomanov
Hello, I have one more SQL query question - the people on this list have been very helpful in the past, so thank you! I'm trying to create a trigger that would delete unreferenced rows from a table. Let's say the schema is like this: TABLEA ( ID INTEGER PRIMARY KEY, REFB INTEGER ); TABLEB ( ID