jakebur01 Posted May 19, 2007 Share Posted May 19, 2007 Here's my issue. I have 80,000 products I am creating categories for. I am attemping to do an update on a column that already has a three character symbol. I am replacing the three character symbols with my new symbol on each row in the table according to which product I want in the category. This query I have been trying is throwing me back errors. update books set catid = "J01" where isbn = '30-097' and where isbn = '30-072' and where isbn = '30-022' and where isbn = '30-918' and where isbn = '30-132' and where isbn = '30-075' and where isbn = '30-923' and where isbn = '30-044' and where isbn = '30-825' and where isbn = '30-920' and where isbn = '30-101' and where isbn = '30-809' and where isbn '69-002' and where isbn = '30-929' and where isbn = '30-761' and where isbn = '30-104' and where isbn = '30-811' and where isbn = '69-003' and where isbn = '30-105' and where isbn = '30-106' and where isbn = '30-094' and where isbn = '30-107' and where isbn = '30-827' and where isbn = '30-924' and where isbn = '30-108' and where isbn = '30-134' and where isbn = '30-048' and where isbn = '30-820' and where isbn = '30-926' and where isbn = '30-049' and where isbn = '30-803' and where isbn = '69-006' and where isbn = '30-925' and where isbn = '30-039' and where isbn = '30-029' and where isbn = '30-821' and where isbn = '69-829' and where isbn = '30-930' and where isbn = '30-033' and where isbn = '30-824' and where isbn = '69-333' and where isbn = '30-915' and where isbn = '30-700' and where isbn = '30-813' and where isbn = '30-038' and where isbn = '30-720' and where isbn = '30-731' and where isbn = '30-928' and where isbn = '30-710' and where isbn = '30-800' and where isbn = '69-036' and where isbn = '30-927' and where isbn = '30-961'; My quesion is: Does anyone have any suggestions on a better way to do this? or How could I get the above query to work? Thank you, Jake Quote Link to comment https://forums.phpfreaks.com/topic/52088-solved-updating-table-data/ Share on other sites More sharing options...
pocobueno1388 Posted May 19, 2007 Share Posted May 19, 2007 You should store all the isbn numbers in an array then loop through to update them all...like this: <?php $isbn = array ("30-800", "69-036", "11-111", "22-222", "33-3333"); for ($i=0; $i < count($isbn); $i++){ mysql_query("UPDATE books SET catid = "J01" WHERE isbn = ". $isbn[$i]. ""); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/52088-solved-updating-table-data/#findComment-256810 Share on other sites More sharing options...
jitesh Posted May 19, 2007 Share Posted May 19, 2007 I think you are trying to do update books set catid = "J01" where isbn IN ('30-097','30-072','30-022',...................); Quote Link to comment https://forums.phpfreaks.com/topic/52088-solved-updating-table-data/#findComment-256813 Share on other sites More sharing options...
jakebur01 Posted May 19, 2007 Author Share Posted May 19, 2007 These worked GREAT!! Thank you so much. It really saves me a lot of time not having to type all of those and where isbn = over and over.... this is my first time really playing with the update command.. I'll hang on to that php code using update as well.. Thank you all.. `Jake Quote Link to comment https://forums.phpfreaks.com/topic/52088-solved-updating-table-data/#findComment-256816 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.