Passing variables to SQL query keywords
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,
|All times are GMT. The time now is 01:26 PM.|
Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.