Hi,

        Here's a little trick, that another aussie at London.pm told me
... which I'd forgotten, but have now just remembered, and thought others
may find interesting.

        Sometimes I need to dynamically create the "where" clause of an 
SQL statement. For example:

        select * from table where a = 1 and b = 2 and c = 2

        However, depending on the user input I may not want to include 
some or all of the "and" clauses. This means that I have to conditionally 
concatenate "and" ... which makes things a bit messy.

        Here is an SQL trick that solves this problem:

        select * from table
        where   1 = 1           
        and     a = 1   etc.

        It just makes things a bit easier ... any other tricks out there?
        

Nige


-- 
Nigel Hamilton
Turbo10 Metasearch Engine

email:  [EMAIL PROTECTED]
tel:    +44 (0) 207 987 5460
fax:    +44 (0) 207 987 5468
________________________________________________________________________________
http://turbo10.com              Search Deeper. Browse Faster.


Reply via email to