Skip to content

Instantly share code, notes, and snippets.

@spencerfinnell
Created July 9, 2018 18:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save spencerfinnell/03b30c698960331884f05a666141b4f6 to your computer and use it in GitHub Desktop.
Save spencerfinnell/03b30c698960331884f05a666141b4f6 to your computer and use it in GitHub Desktop.
SELECT SQL_CALC_FOUND_ROWS wp_4_posts.ID
FROM wp_4_posts 
INNER JOIN wp_4_postmeta
ON ( wp_4_posts.ID = wp_4_postmeta.post_id )
WHERE 1=1 
AND ( wp_4_posts.ID NOT IN ( 
SELECT object_id 
FROM wp_4_term_relationships 
WHERE term_taxonomy_id IN (7) ) )
AND ( ( wp_4_postmeta.meta_key = '_price'
AND CAST(wp_4_postmeta.meta_value AS DECIMAL(10,2)) BETWEEN '1'
AND '82' ) )
AND wp_4_posts.post_type = 'product'
AND (wp_4_posts.post_status = 'publish'
OR wp_4_posts.post_status = 'private')
GROUP BY wp_4_posts.ID
ORDER BY wp_4_posts.post_date DESC, wp_4_posts.ID DESC
LIMIT 0, 30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment