Advertisement
businessdad

FB Advanced WooCommerce - Rewritten query

Jun 22nd, 2016
224
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MySQL 0.73 KB | None | 0 0
  1. -- Ref. https://www.facebook.com/groups/advanced.woocommerce/permalink/1339363232744759/
  2. SELECT
  3.     posts.ID
  4. FROM
  5.     posts
  6.     INNER JOIN
  7.     term_relationships ON
  8.         (posts.ID = term_relationships.object_id)
  9.     INNER JOIN
  10.     postmeta ON
  11.         ( posts.ID = postmeta.post_id )
  12.     INNER JOIN
  13.     postmeta AS mt1 ON
  14.         ( posts.ID = mt1.post_id )
  15. WHERE
  16.         (term_relationships.term_taxonomy_id IN (2365,2366,2367,2374,2375,2376,2385,2386) )
  17.         AND (postmeta.meta_key = '_price' AND ( ( mt1.meta_key = '_visibility' AND mt1.meta_value IN
  18. ('visible','catalog') ) ) )
  19.         AND posts.post_type = 'product'
  20.         AND (posts.post_status = 'publish' OR posts.post_status = 'private')
  21. ORDER BY
  22.     postmeta.meta_value DESC,
  23.     posts.ID DESC
  24. LIMIT 0, 10;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement