Skip to content

Instantly share code, notes, and snippets.

@drrobotnik
Created May 12, 2014 21:28
Show Gist options
  • Save drrobotnik/7c2a33cb9127b7a6dc54 to your computer and use it in GitHub Desktop.
Save drrobotnik/7c2a33cb9127b7a6dc54 to your computer and use it in GitHub Desktop.
wp 3.9 search results
Search: Hello World
SELECT SQL_CALC_FOUND_ROWS wp_posts.id
FROM wp_posts
WHERE 1 = 1
AND ( ( ( wp_posts.post_title LIKE '%hello%' )
OR ( wp_posts.post_content LIKE '%hello%' ) )
AND ( ( wp_posts.post_title LIKE '%world%' )
OR ( wp_posts.post_content LIKE '%world%' ) ) )
AND wp_posts.post_type IN ( 'post', 'page', 'attachment', 'product',
'reviews' )
AND ( wp_posts.post_status = 'publish'
OR wp_posts.post_author = 1
AND wp_posts.post_status = 'private' )
ORDER BY ( CASE
WHEN wp_posts.post_title LIKE '%hello world%' THEN 1
WHEN wp_posts.post_title LIKE '%hello%'
AND wp_posts.post_title LIKE '%world%' THEN 2
WHEN wp_posts.post_title LIKE '%hello%'
OR wp_posts.post_title LIKE '%world%' THEN 3
WHEN wp_posts.post_content LIKE '%hello world%' THEN 4
ELSE 5
end ),
wp_posts.post_date DESC
LIMIT 0, 10
Search: "Hello World"
SELECT SQL_CALC_FOUND_ROWS wp_posts.id
FROM wp_posts
WHERE 1 = 1
AND (( ( wp_posts.post_title LIKE '%hello world%' )
OR ( wp_posts.post_content LIKE '%hello world%' ) ))
AND wp_posts.post_type IN ( 'post', 'page', 'attachment', 'product',
'reviews' )
AND ( wp_posts.post_status = 'publish'
OR wp_posts.post_author = 1
AND wp_posts.post_status = 'private' )
ORDER BY wp_posts.post_title LIKE '%hello world%' DESC,
wp_posts.post_date DESC
LIMIT 0, 10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment