Re: [sqlite] Subselect question

2008-11-03 Thread Ingo Koch
Igor Tandetnik wrote: > How about this: > > select A.*, B.* > from TBOOKING A, TBOOKING B > where A.EVENTTYPE = 3 and B.ID = ( > select min(C.ID) from TBOOKING C > where C.EVENTTYPE = 4 and C.ID > A.ID > ); > > Igor Tandetnik Igor, you are my hero ;-) I've tried a subselect in the

Re: [sqlite] Subselect question

2008-11-03 Thread Igor Tandetnik
Griggs, Donald <[EMAIL PROTECTED]> wrote: > -Original Message- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] > On Behalf Of Ingo Koch Sent: Monday, November 03, 2008 2:15 PM >> SELECT t.*, u.* >> FROM TBOOKING AS t LEFT JOIN TBOOKING as u ON t.ID+1=u.ID WHERE >>

Re: [sqlite] Subselect question

2008-11-03 Thread Ingo Koch
Griggs, Donald wrote: > When you wrote: "... but I didn't want to keep track of an additional > ID in the application but instead let the database do the work." > > I don't think I understand what logic the database is supposed to use to > determine this. If you were talking to a database

Re: [sqlite] Subselect question

2008-11-03 Thread Griggs, Donald
-Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Ingo Koch Sent: Monday, November 03, 2008 2:15 PM To: General Discussion of SQLite Database Subject: Re: [sqlite] Subselect question Csaba wrote: > Firstly, perhaps you should be linking the st

Re: [sqlite] Subselect question

2008-11-03 Thread Ingo Koch
Csaba wrote: > Firstly, perhaps you should be linking the start and stop event across > a common id rather than relying on a start and stop appearing as > consecutive entries. Without knowing more about where your database > comes from it's hard to say. > > If you insist on keeping the current

Re: [sqlite] Subselect question

2008-11-03 Thread Dan
>> Here is some test data: >> - >> CREATE TABLE "TBOOKING" ( >> "ID" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, >> "EVENTTIMESTAMP" TIMESTAMP NOT NULL, >> "EVENTTYPE" INTEGER NOT NULL, >> "EMPLOYEE" INTEGER); >> >> INSERT INTO "TBOOKING" VALUES(42,'2008-09-22

Re: [sqlite] Subselect question

2008-11-02 Thread Dan
On Nov 3, 2008, at 6:39 AM, Ingo Koch wrote: > Hi, > > I've got a question concerning a query with subselects. > I have a table with stores pairs of events. one of the events is > kind of a start event and the other one is a stop event. > Each event is stored in its own row. What I'm trying to

Re: [sqlite] Subselect question

2008-11-02 Thread Csaba
Firstly, perhaps you should be linking the start and stop event across a common id rather than relying on a start and stop appearing as consecutive entries. Without knowing more about where your database comes from it's hard to say. If you insist on keeping the current structure, here's a way to

[sqlite] Subselect question

2008-11-02 Thread Ingo Koch
Hi, I've got a question concerning a query with subselects. I have a table with stores pairs of events. one of the events is kind of a start event and the other one is a stop event. Each event is stored in its own row. What I'm trying to achive is to get a view which contains rows with the start

Re: [sqlite] Subselect question

2008-07-09 Thread D. Richard Hipp
On Jul 9, 2008, at 3:23 PM, Shawn Wilsher wrote: > Hey all, > > Quick (and hopefully simple) question regarding subselects in a where > clause. Does sqlite cache the values of a subselect so it doesn't > have to run the query each time it evaluates a row? > > Example: > SELECT * > FROM foo >

[sqlite] Subselect question

2008-07-09 Thread Shawn Wilsher
Hey all, Quick (and hopefully simple) question regarding subselects in a where clause. Does sqlite cache the values of a subselect so it doesn't have to run the query each time it evaluates a row? Example: SELECT * FROM foo WHERE id NOT IN (SELECT id FROM bar) Cheers, Shawn