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
>> t.EVENTTYPE+1=u.EVENTTYPE
>
> The problem with the join is, that although t.ID+1=u.ID is most often
> the case, it's not guaranteed that t.ID+1=u.ID. Users may undo the
> last
> booking (by deleting it from the database) which is why the subselects
> have u.ID>t.ID as part of the where clause. So the join, no matter how
> simple and elegant it would be, isn't a choice.
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
_______________________________________________
sqlite-users mailing list
[email protected]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users