Page 1 of 1

IF in MySql Query

Posted: Sat Apr 12, 2003 5:49 am
by nmotion
I know this may be a stupid question but here goes...

Is there a way to use IF, ELSE etc. in a MySql query in PHP ?

I need to check each variable before updating a field in the DB. I know I can make a Query per IF ELSE but if I could incorporate it in one query it would be great.

Posted: Sat Apr 12, 2003 6:00 am
by twigletmac
I found this:
http://www.mysql.com/doc/en/Control_flow_functions.html

But it may be simpler to use PHP to build the query - not write one query per condition but have one query which is dynamic and built based on whatever information needs to be updated.

Mac