On Dec 5, 2007 8:48 AM, Hiep Nguyen <[EMAIL PROTECTED]> wrote: > hi list, > > i have a loop to update my table: > > update tbl_idea set col1 = 'text1', col2 = NOW() where ideaID = 1; > update tbl_idea set col1 = 'text2', col2 = NOW() where ideaID = 5; > ... > update tbl_idea set col1 = 'textzzz', col2 = NOW() where ideaID = XXX; > > my question is can i combine above statements into one statement so i can > only do update only once?
Use a CASE statement: update tbl_idea set col1 = CASE WHEN ideaID = 1 THEN 'text1', WHEN .... END WHERE ideaID IN (1, ....) -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]