How about UPDATE myTable SET DueField = 0, StatusField = if(StatusField='O', 'C', StatusField) WHERE PrimaryKeyField = 'XYZXYZ'
See http://www.mysql.com/doc/C/o/Control_flow_functions.html for more info on IF() function. -steve At 12:41 PM -0600 12/7/01, Chris Boget wrote: >Is there a way to do this? If so, I've not been able to >find it in the documentation... > >I have 3 fields: > >PrimaryKeyField >StatusField >DueField > >I want to update the DueField to 0 (zero) where the >PrimaryKeyField = "XYZXYZ". I also want to update >the StatusField for those records to be equal to "C" >when it's equal to "O" but not any other value. Is there >a way to do this all in one query? > ><pseudocode> > >UPDATE myTable SET >DueField = 0, >( StatusField = "C" WHEN StatusField = "O") >WHERE PrimaryKeyField = "XYZXYZ"; > ></pseudocode> > >Can something like that be done? > >Chris > -- +------------------------------------------------------------------------+ | Steve Edberg [EMAIL PROTECTED] | | University of California, Davis (530)754-9127 | | Programming/Database/SysAdmin http://pgfsun.ucdavis.edu/ | +------------------------------------------------------------------------+ | "Restriction of free thought and free speech is the most dangerous of | | all subversions. It is the one un-American act that could most easily | | defeat us." | | - Supreme Court Justice (1939-1975) William O. Douglas | +------------------------------------------------------------------------+ --------------------------------------------------------------------- Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php