Created
September 7, 2020 05:02
-
-
Save atapatel/1566cf180e65fea44ca078f445c6f4ed to your computer and use it in GitHub Desktop.
KB Query
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT SQL_CALC_FOUND_ROWS wp_570_posts.ID | |
FROM wp_570_posts | |
INNER JOIN wp_570_postmeta AS fdi1 ON (wp_570_posts.ID = fdi1.post_id) | |
INNER JOIN wp_570_postmeta AS fdi2 ON (wp_570_posts.ID = fdi2.post_id) | |
INNER JOIN wp_570_postmeta AS fdi_stocknumberpostmeta ON wp_570_posts.id = fdi_stocknumberpostmeta.post_id | |
AND fdi_stocknumberpostmeta.meta_key = 'stock' | |
WHERE 1=1 | |
AND ( | |
wp_570_posts.post_title REGEXP '/\b(new)\b/' | |
OR wp_570_posts.post_excerpt REGEXP '/\b(new)\b/' | |
OR wp_570_posts.post_content REGEXP '/\b(new)\b/' | |
) | |
AND (wp_570_posts.post_password = '') | |
AND wp_570_posts.post_type = 'vehicle' | |
AND (wp_570_posts.post_status = 'publish') | |
AND fdi1.meta_key = 'feed_id' | |
AND fdi2.meta_key = 'dateinstock' | |
OR wp_570_posts.post_name REGEXP '/\b(new)\b/' | |
OR fdi_stocknumberpostmeta.meta_value REGEXP '/\b(new)\b/' | |
GROUP BY wp_570_posts.ID | |
ORDER BY CASE | |
WHEN (fdi1.meta_value = 'h_northbaynissan') THEN 1 | |
ELSE 2 | |
END, | |
CAST(fdi2.meta_value AS DECIMAL) ASC | |
LIMIT 420,20 |
Author
atapatel
commented
Sep 11, 2020
SELECT
SQL_CALC_FOUND_ROWS wp_577_posts.ID
FROM
wp_577_posts
INNER JOIN
wp_577_postmeta AS fdi1
ON (wp_577_posts.ID = fdi1.post_id)
INNER JOIN
wp_577_postmeta AS fdi2
ON (wp_577_posts.ID = fdi2.post_id)
INNER JOIN
wp_577_postmeta AS fdi_stocknumberpostmeta
ON wp_577_posts.id = fdi_stocknumberpostmeta.post_id
AND fdi_stocknumberpostmeta.meta_key = 'stock'
WHERE
1 = 1
AND (
wp_577_posts.post_title REGEXP '[[:<:]]324[[:>:]]'
OR wp_577_posts.post_excerpt REGEXP '[[:<:]]324[[:>:]]'
OR wp_577_posts.post_content REGEXP '[[:<:]]324[[:>:]]'
)
AND
(
wp_577_posts.post_password = ''
)
AND wp_577_posts.post_type = 'vehicle'
AND
(
wp_577_posts.post_status = 'publish'
)
AND fdi1.meta_key = 'feed_id'
AND fdi2.meta_key = 'dateinstock'
OR
(
(wp_577_posts.post_name LIKE '%324')
OR
(
wp_577_posts.post_name LIKE '%324%'
)
OR
(
wp_577_posts.post_name LIKE '324%'
)
)
OR
(
( fdi_stocknumberpostmeta.meta_value LIKE '%324'
OR fdi_stocknumberpostmeta.meta_value LIKE '%324%'
OR fdi_stocknumberpostmeta.meta_value LIKE '324%' )
)
GROUP BY
wp_577_posts.ID
ORDER BY
CASE
WHEN
(
fdi1.meta_value = 'h_goldenstatenissan'
)
THEN
1
ELSE
2
END
, CAST(fdi2.meta_value AS DECIMAL) ASC LIMIT 0, 20
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment