Hi,

I'm looking for some SQL advice. I have a query which is used as the
base of a filter. At the moment I am using:

SELECT * FROM table WHERE (1=? OR foo=?);

The actual query is more complex and uses multiple of the constructions
in this WHERE clause. If I wanted to select on the foo column then I
would bind (0, 'desired-foo'). If I didn't then I would bind (1, '').
There is an index on the foo column, but this construction precludes the
use of it even when I have a specific foo that I want. The idea behind
this was to prepare a single select query, and then just reuse it all of
the time.

I am thinking now that this is false economy and it would be better
(faster) to dynamically assemble the SQL, prepare, step, finalize each
time instead? At the very least it seems like it should enable indexes
to be used where available.

Regards,
Brodie

-----------------------------------------------------------------------------
To unsubscribe, send email to [EMAIL PROTECTED]
-----------------------------------------------------------------------------

Reply via email to