Passing variables to SQL query keywords

Discussion in 'General Computer Support' started by enthusiast, Jun 7, 2010.

  1. enthusiast

    enthusiast

    Joined:
    Nov 17, 2008
    Messages:
    1
    Hey everyone,

    I need to pass "AND or OR" as variables in a sql query. What I need to do is:

    Select * from table
    where (if field1 is not null)field1 = value
    AND (if field2 has some value) OR (if field2 is NULL) field2 = value
    AND (if field3 has some value) OR (if field3 is NULL) field3 = value

    and the list goes like this. I have more than 5 fields.. so I can not have 5^2 queries using id else statements.

    Do you have any simple solution to do this ?

    Thanks in advance,
     
    Last edited: Jun 7, 2010
    enthusiast, Jun 7, 2010
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Nick
    Replies:
    0
    Views:
    932
  2. Who
    Replies:
    1
    Views:
    480
    A Hess
    Dec 6, 2003
  3. Michael Volland

    Firefox 0.9.3 Smart Keywords disable?

    Michael Volland, Oct 9, 2004, in forum: Firefox
    Replies:
    0
    Views:
    408
    Michael Volland
    Oct 9, 2004
  4. Michael Volland

    Firefox 0.9.3 Smart Keywords disable?

    Michael Volland, Oct 9, 2004, in forum: Firefox
    Replies:
    0
    Views:
    424
    Michael Volland
    Oct 9, 2004
  5. chopster
    Replies:
    2
    Views:
    4,226
    °Mike°
    Aug 24, 2004
Loading...

Share This Page