shadowskill Posted March 2, 2013 Share Posted March 2, 2013 $rem1 = "UPDATE `subjecttaken` SET `Remarks`= 'FAILED' WHERE `Grade` < '75' and `SNum`='$SNum' "; mysql_query($rem1); $rem2 = "UPDATE `subjecttaken` SET `Remarks`= 'PASSED' WHERE `Grade` > '75' and `SNum`='$SNum' "; mysql_query($rem2); $rem3 = "UPDATE `subjecttaken` SET `Remarks`= 'No Grade' WHERE `Grade` = '' and `SNum`='$SNum' "; mysql_query($rem3); $rem4 = "UPDATE `subjecttaken` SET `Remarks`= 'PASSED' WHERE `Grade` = '75' and `SNum`='$SNum' "; mysql_query($rem4); $rem5 = "UPDATE `subjecttaken` SET `Remarks`= 'INCOMPLETE' WHERE `Grade` = 'INC' and `SNum`='$SNum' "; mysql_query($rem5); My problem about this is it loads too long so im guessing its because of i have lots to update? There is a possibility of combing all of them into one right? That will also lessen the loading? Quote Link to comment https://forums.phpfreaks.com/topic/275124-how-to-combine-multiple-updates/ Share on other sites More sharing options...
teynon Posted March 2, 2013 Share Posted March 2, 2013 (edited) You can use a long conditional or a CASE: UPDATE `subjecttaken` SET `Remarks` = IF (`Grade` = 'INC', 'INCOMPLETE, IF (`Grade` = '75', 'PASSED', IF (`Grade` = '', 'No Grade', IF (`Grade` > 75, 'PASSED', 'FAILED')))) WHERE `SNum` = '$SNum' Edited March 2, 2013 by teynon Quote Link to comment https://forums.phpfreaks.com/topic/275124-how-to-combine-multiple-updates/#findComment-1416057 Share on other sites More sharing options...
Barand Posted March 2, 2013 Share Posted March 2, 2013 I gave you an example of how to do this only yesterday http://forums.phpfreaks.com/topic/275092-sql-problem/?do=findComment&comment=1415874 Quote Link to comment https://forums.phpfreaks.com/topic/275124-how-to-combine-multiple-updates/#findComment-1416063 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.