Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

PHP SQL Alter table question


Guest

Recommended Posts

I have all of the mods working okay and have uploaded my products but, with a 2600+ product list, am hoping to add the pictures in a bit at a time. I ran an SQL query along these lines for each product:

 

INSERT INTO `products` VALUES (30, 999, 'AmerFA: 30', 'picturecoming.gif', '7.7500', '2004-01-13 10:41:33', '2004-01-13 21:39:34', NULL, '0.03', 1, 0, 0, 0);

 

What I would like to do now is figure out how to overwrite *just* the products_image portion of the products table to add the actual pictures to each product- can I do this with an alter table query? Or do I have to add it into the products query and drop that in all over again?

Link to comment
Share on other sites

I have all of the mods working okay and have uploaded my products but, with a 2600+ product list, am hoping to add the pictures in a bit at a time. I ran an SQL query along these lines for each product:

 

INSERT INTO `products` VALUES (30, 999, 'AmerFA: 30', 'picturecoming.gif', '7.7500', '2004-01-13 10:41:33', '2004-01-13 21:39:34', NULL, '0.03', 1, 0, 0, 0);

 

What I would like to do now is figure out how to overwrite *just* the products_image portion of the products table to add the actual pictures to each product- can I do this with an alter table query? Or do I have to add it into the products query and drop that in all over again?

You can back up your database first then use word processing tool to edit the sql file, then restore the database, that's faster

Link to comment
Share on other sites

I might have to go that way- what about prepping the sql, dropping the products_images table and then replacing with the new info? Would that work if I did it as an INSERT?

Link to comment
Share on other sites

Okay, I figured out how to word this for myPHPadmin and just updated images for 734 products in 5 minutes (yay!) so, in case anyone else needs it:

 

UPDATE `products` SET `products_image` = 'Art Nouveau/images/PlaceClichy-Grasset.gif',`products_date_available` = NULL WHERE `products_id` = '7' LIMIT 1 ;

 

products would be the table you want to change and is a variable- depending on what you're trying to update you may need to change it in the query

products_image is the specific column you're updating and is also a variable

Art Nouveau/images/PlaceClichy-Grasset.gif well, obviously yours isn't going to be the same, this is the new information and will OVERWRITE the old. In my case, I used "picturecoming.gif" for all products and am now replacing with the correct images for each product.

products_id' = '7'- you will put the correct identifier here. The query will use this to identify which record to overwrite. I'm not sure if the date_available would need to have the NULL changed, this may be an identifier as well.

 

If you use this, backup your database and use with caution- I have the feeling that improperly done you could really screw yourself up.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...