Jump to content

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/52088-solved-updating-table-data/
Share on other sites

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]. "");

}

?>

 

 

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.