A.V.E Posted May 29, 2021 Share Posted May 29, 2021 Hello. I have been importing products from csv-file without categories. Now I'm fiddling around and have this situation: som products (lets say id 15,16,17) have got category, but all have position 0. Actually there are bigger amount. I found a query to alter the position semi-manually: UPDATE ps_category_product INNER JOIN (SELECT id_product FROM ps_category_product WHERE id_product in(15,16,17) and position = 0 LIMIT 1) as t2 using(id_product) SET position = 1; This is a way where the updates are limited to one row. But I wanted to make it more automatic and tried: UPDATE ps_category_product INNER JOIN (SELECT id_product FROM ps_category_product WHERE id_product in(15,16,17) and position = 0 LIMIT 1) as t2 using(id_product) SET position = SELECT MAX(position)+1 FROM ps_category_product as t3 WHERE id_product IN (15,16,17); But it doesn't work, even though the query SELECT MAX(position)+1 FROM ps_category_product as t3 WHERE id_product IN (15,16,17); works. I wonder why. Link to comment Share on other sites More sharing options...
musicmaster Posted May 29, 2021 Share Posted May 29, 2021 It would be much easier with product_sort from Prestools (it is free). I would need to think really hard to think up the right query. This is the kind of question you should ask on a Mysql forum. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now