Answer the question
In order to leave comments, you need to log in
How to remove extra category from sql query?
Good evening. There is a sql query that displays the last 12 added products.
SELECT * FROM
(SELECT resource.pagetitle,resource.uri,product.id,product.price FROM `ms2_products` AS product
INNER JOIN `site_content` AS resource
ON resource.id = product.id
ORDER BY product.id DESC
LIMIT 12) s1
LEFT JOIN
(SELECT img.url AS thumb,img.product_id FROM `ms2_product_files` AS img
WHERE img.path LIKE "%360x270%" AND img.rank=0
ORDER BY img.product_id DESC
LIMIT 12) s2
ON s2.product_id = s1.id
ORDER BY s1.id DESC
LIMIT 12
`site_content`
, the price in `ms2_products`
, the link to the image in `ms2_product_files`
. We connect all this by id through join
. resource.parent
. Tried to do it throughON resource.id = product.id and resource.parent !=9231
but img.url
immediately gives NULL or tried to remove the category by referenceON resource.id = product.id where resource.uri not like "%price%"
which is also NULL. Answer the question
In order to leave comments, you need to log in
And so?
SELECT resource.pagetitle, resource.uri, product.id, product.price, img.url AS thumb
FROM `ms2_products` AS product
JOIN `site_content` AS resource ON resource.id = product.id
LEFT JOIN `ms2_product_files` AS img ON img.product_id = product.id
WHERE img.path LIKE "%360x270%" AND img.rank=0
AND <добавить новое условие>
ORDER BY product.id DESC
LIMIT 12
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question