Jump to content


Photo

mysql update query


  • Please log in to reply
2 replies to this topic

#1 dootch

dootch
  • Members
  • Pip
  • Newbie
  • 8 posts

Posted 03 April 2006 - 10:58 PM

I forgot to add an image column to my db I just want it to be vendor_id.jpg I figure its something close to this but I cant get it.
UPDATE `products` SET `image` = vendor_id,'.jpg'

Help please

#2 ToonMariner

ToonMariner
  • Members
  • PipPipPip
  • Advanced Member
  • 3,342 posts
  • LocationNewcastle upon Tyne, UK

Posted 03 April 2006 - 11:25 PM

If you have phpmyadmin then just go in and add your column with that file as teh default value.

If you HAVE to do it through php then..

$query = mysql_query("ALTER TABLE `image` ADD `im` VARCHAR( 255 ) DEFAULT 'image.jpg' NOT NULL ");

now varchar limits you to 255 characters - if you need more then use teh text datatype; NOTE you cannot set a default value for text type so you will have to do and extra update after.

PS if that fails it will be down to the privilages you have on teh database
follow me on twitter @PHPsycho

#3 dootch

dootch
  • Members
  • Pip
  • Newbie
  • 8 posts

Posted 04 April 2006 - 10:04 PM

Thanks Solved
UPDATE products SET image = CONCAT(product_sku, '.jpg ')





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users