Advertisement
Guest User

Untitled

a guest
Jan 27th, 2020
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MySQL 0.84 KB | None | 0 0
  1. update fahasa_suborder
  2. set status = 'unassigned'
  3. where suborder_id in (
  4. select so.suborder_id
  5. from (
  6. select b.*
  7. from (
  8. select a.order_id, a.suborder_id, a.status, a.bookstore_id
  9. from (
  10. select so.order_id, so.suborder_id, so.status, so.bookstore_id
  11. from fahasa_suborder so
  12. join fhs_sales_flat_order o on so.order_id = o.increment_id
  13. where so.bookstore_id = 4
  14. and o.don_si is null
  15. and o.protect_code in ('flashsale_manual','tiki19_manual')
  16. ) a
  17. join fahasa_suborder so on so.order_id = a.order_id
  18. group by a.order_id having count(so.order_id) = 1
  19. ) b
  20. left join fahasa_bookstore_log l on l.order_id = b.order_id and l.action in ('cancelOrder','cancelOrderViaFahasaApp','cancelOrderViaWebsite')
  21. where l.id is null
  22. ) c
  23. join fahasa_suborder so on so.suborder_id = c.suborder_id and c.order_id = so.order_id
  24. where so.status != 'canceled'
  25. );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement