Jump to content

If In Mysql_Query- Solved With Thanks


niche

Recommended Posts

I'm trying to write an if in a mysql query. Based on: http://dev.mysql.com/doc/refman/5.0/...statement.htmlI came up with this, but no joy.

mysql_query("UPDATE skew_trkg_slave IF observations_needed = observations_completed THEN SET minor_cycle_completed = '1';WHERE " . $skew_trkg_slave_where . "") or die(mysql_error());

How close am I?

Link to comment
Share on other sites

The reference you linked to is for functions, not SQL queries. This is for queries: http://dev.mysql.com/doc/refman/5.0/en/control-flow-functions.html#function_if The if statement returns a value, so that value would be the value for the field to update. e.g.: UPDATE table SET field = IF(...) WHERE ....

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...