Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

IF Statement in SQL Query

Status
Not open for further replies.

andy98

Programmer
Jul 7, 2000
120
GB
Hi
I know this is possible in Coldfusion but can this be done in PHP.

I have a search form with these fields:
Order_Number
Cust_Firstname
Cust_Surname

This form submits to a page with a query where I would like to be able to test for the existence of these fields within the SQL query - so that I can dislay the results based upon what fields have values.

Can anyone help?

 
That just returns everything!

Any other ideas?
 
hmm..
you only want to look for the fields, not the field values?

if you use OR, it will return true, if any of them are true.

If you use AND, all has to return true

WHERE 1 > 2 OR 2 < 3; <- true, even if 1 > 2 == false

WHERE 1 > 2 AND 2 < 3; <- false, since both are not true

Olav Alexander Mjelde
Admin & Webmaster
 
It's OK I have resolved this by eliminating one of the fields and using an IF Statement outside of the query to select a specific query to run.

Many Thanks!



 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top