Subject Re: SQL question
Author Svein Erling
> Is this ok?
>
> SELECT MyRec, MyRec1 FROM MyRecTable WHERE MyDateField IN
> (SELECT OtherDate FROM OtherTable WHERE
> (OtherDate >= '1/1/2003 00:00:00')
> AND
> (OtherDate <= '12/31/2003 00:00:00'))
> ORDER BY
> MyDateField
>
> Or should I use a Join if possible?

Well, using IN <subselect> used to be very slow, though it may be
improved in Firebird 1.5. Rewriting the above statement to

SELECT MyRec, MyRec1 FROM MyRecTable WHERE EXISTS (
(SELECT * FROM OtherTable WHERE
MyRecTable.MyDateField = OtherTable.OtherDate AND
OtherDate BETWEEN '1/1/2003 00:00:00' AND '12/31/2003 00:00:00')
ORDER BY
MyDateField

Using JOIN is generally a good idea, but not always possible.

HTH,
Set