Page 1 of 1
[SOLVED]Multiple Manufacturers ID DB - combine in 1
Posted: Wed Feb 03, 2021 4:21 pm
by ideep13
Hi,
Can please someone help me with DATABASE code?
I have combined two stores into 1, so I have now multiple manufacturers and different products are assigned to them from each store. Before I can delete the duplicates, I need to assign the right id to right products. So..
If manufacturer id is 11
And the same manufacturer is 57
How can I assign a right manufacturer to a products that have 57 id, but needs to be 11 now.
Can you send me the right code so I can run in SQL?
Re: Multiple Manufacturers ID DB - combine in 1
Posted: Wed Feb 03, 2021 6:40 pm
by paulfeakins
First check that you're selecting the right products:
Code: Select all
SELECT * FROM `ocuy_product`
WHERE manufacturer_id = 5
Then AFTER BACKING UP YOUR DATABASE, you can add an update in there:
Code: Select all
UPDATE * FROM `ocuy_product`
SET manufacturer_id = 11
WHERE manufacturer_id = 5
Sometimes to be safe you can add LIMIT 1 to the end so even worst case it only affects one row.
Re: Multiple Manufacturers ID DB - combine in 1
Posted: Wed Feb 03, 2021 6:51 pm
by ideep13
is there any other way? selecting products manually is taking a lot of time.
isn't there a magical command where you can replace id 11 with 57?
[SOLVED] Multiple Manufacturers ID DB - combine in 1
Posted: Wed Feb 03, 2021 7:05 pm
by ideep13
OK.If anyone needs this - this is the command and back up the DB before you are doing this
Code: Select all
UPDATE `oc_product` SET manufacturer_id = 255 WHERE manufacturer_id = 5
255 is the new, or existing manufacturer_id which you need to assign to the product and 5 is the manufacturer_id which you later will delete/remove
Got help from stackoverflow
Re: [SOLVED] Multiple Manufacturers ID DB - combine in 1
Posted: Thu Feb 04, 2021 5:56 pm
by paulfeakins
ideep13 wrote: ↑Wed Feb 03, 2021 7:05 pm
OK.If anyone needs this - this is the command and back up the DB before you are doing this
Code: Select all
UPDATE `oc_product` SET manufacturer_id = 255 WHERE manufacturer_id = 5
255 is the new, or existing manufacturer_id which you need to assign to the product and 5 is the manufacturer_id which you later will delete/remove
Got help from stackoverflow
What are you talking about, this is the answer I gave you above
