IF in MySql Query

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
nmotion
Forum Commoner
Posts: 32
Joined: Wed Jan 22, 2003 6:53 am

IF in MySql Query

Post 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.
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post 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
Post Reply