Advertisement
phpface

mySQL - NL

Dec 25th, 2018
387
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. SELECT max(oim2.meta_value/oim3.meta_value) FROM `wp_woocommerce_order_itemmeta` as oim
  2. INNER join wp_woocommerce_order_items as oi
  3.  
  4. on oim.order_item_id = oi.order_item_id
  5.  
  6. inner join wp_woocommerce_order_itemmeta as oim2
  7.  
  8. on oim.order_item_id = oim2.order_item_id
  9.  
  10. inner join wp_woocommerce_order_itemmeta as oim3
  11.  
  12. on oim.order_item_id = oim3.order_item_id
  13.  
  14. inner join wp_postmeta as pm
  15. ON pm.post_id = oi.order_id
  16.  
  17. where pm.meta_key = '_customer_user' and pm.meta_value = 14
  18.  
  19. and oim.meta_key = '_product_id'
  20.  
  21. and oim.meta_value = 215
  22.  
  23. and oim2.meta_key = '_line_subtotal'
  24.  
  25. and oim3.meta_key = '_qty'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement