Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

update product price by manufacturer via mysql command


kenkja

Recommended Posts

Hi All

 

I am trying to update product prices for a specific manufacturer id, will this mysql command work

 

update

products

set

products_price

=

products_price

*

1.10

WHERE

manufacturers_id

LIKE

'5'

;

 

or

 

update

products

set

products_price

=

products_price

*

1.10

WHERE

manufacturers_id =

'5'

;

 

I know I should try this offline first and would do normally but recently had to change computers after a motherboard failure and have not yet got all the necessary stuff into my new computer, so any help would be gratefully recieved.

 

ken

Os-commerce v2.3.3

Security Pro v11

Site Monitor

IP Trap

htaccess Protection

Bad Behaviour Block

Year Make Model

Document Manager

X Sell

Star Product

Modular Front Page

Modular Header Tags

Link to comment
Share on other sites

update `products` set `products_price` = (`products_price` * '1.10') WHERE `manufacturers_id` = '5';

 

Only real difference:

 

1. enclose the 1.10 in single quotes

2. enclose the increase calculation in brackets (which you don't actually need, but I like to use for easy look-see in case of more complicated calculations)

Link to comment
Share on other sites

thanks gary

Os-commerce v2.3.3

Security Pro v11

Site Monitor

IP Trap

htaccess Protection

Bad Behaviour Block

Year Make Model

Document Manager

X Sell

Star Product

Modular Front Page

Modular Header Tags

Link to comment
Share on other sites

all the single quotes are not needed, the field or table names do not contain any spaces

the id is an integer so it doesn't need to be in quotes

1.1 is a number too, so no quotes needed

 

within oscommerce all fields and tables do not contain spaces in their name so you don't need it.

I've seen in oscommerce code a lot of times a single quote surrounding numbers where it doesn't need to, not sure why this is done, as it is not needed and the use of single quotes or back ticks can be quite confusing

KEEP CALM AND CARRY ON

I do not use the responsive bootstrap version since i coded my responsive version earlier, but i have bought every 28d of code package to support burts effort and keep this forum alive (albeit more like on life support).

So if you are still here ? What are you waiting for ?!

 

Find the most frequent unique errors to fix:

grep "PHP" php_error_log.txt | sed "s/^.* PHP/PHP/g" |grep "line" |sort | uniq -c | sort -r > counterrors.txt

Link to comment
Share on other sites

thanks guys happy to say it worked just fine

Os-commerce v2.3.3

Security Pro v11

Site Monitor

IP Trap

htaccess Protection

Bad Behaviour Block

Year Make Model

Document Manager

X Sell

Star Product

Modular Front Page

Modular Header Tags

Link to comment
Share on other sites

kenkja - for what its worth, I think EasyPopulate would make what you want to do much easier

you must be joking, easy populate is great if you have to do a lot of updates and they are not all the same

but you can never beat the speed and ease of a sql update if you know what you are doing

KEEP CALM AND CARRY ON

I do not use the responsive bootstrap version since i coded my responsive version earlier, but i have bought every 28d of code package to support burts effort and keep this forum alive (albeit more like on life support).

So if you are still here ? What are you waiting for ?!

 

Find the most frequent unique errors to fix:

grep "PHP" php_error_log.txt | sed "s/^.* PHP/PHP/g" |grep "line" |sort | uniq -c | sort -r > counterrors.txt

Link to comment
Share on other sites

thanks RMD27, I have looked at easypopulate, but have got so used to uploading products via csv files to phpmyadmin, that it didn't seem worthwhile changing.

 

and I'm with bruyndoncx, the sql command took milliseconds to change around 4500 prices - seems I am gonna have to learn more about what can be done with mysql

 

thanks all

 

ken

Os-commerce v2.3.3

Security Pro v11

Site Monitor

IP Trap

htaccess Protection

Bad Behaviour Block

Year Make Model

Document Manager

X Sell

Star Product

Modular Front Page

Modular Header Tags

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...