Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Одним запросом все дубли UPDATE status = 0

Recommended Posts

Добрый день!

Интересно, задача - выключить дубли в главной категории одним запросом, решаема ?

Но есть еще одно условие, оставить с минимальной ценой. )  

Edited by Pirks
Link to comment
Share on other sites

3 минуты назад, nikifalex сказал:

что за дубли?



тут появилось еще одно условие - не учитывать цену равной 0

Edited by Pirks
Link to comment
Share on other sites

select * from (select pr.sku, pr.product_id, pr.mpn,  des.name, pr.quantity, pr.price from  ocst_product pr
left join ocst_product_to_category cat on cat.product_id = pr.product_id
left join ocst_category_path cpa on cpa.category_id = cat.category_id
left join ocst_product_description des on des.product_id = pr.product_id
where cpa.path_id = [кода категории]
order by des.name, pr.price DESC) dub
group by dub.name
HAVING count(*) > 1

Пока, вот такое решение. 

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...

Important Information

On our site, cookies are used and personal data is processed to improve the user interface. To find out what and what personal data we are processing, please go to the link. If you click "I agree," it means that you understand and accept all the conditions specified in this Privacy Notice.