Suppose in table A i have many rows with column values a,b,c,d.
Out of these, I want 10 rows with column value 'c' while also counting the total number of rows with column value 'c'.
i tried:
select count(*),* from A where column like 'c'; (without limit)
select count(*),* from A where column like 'c' limit 10;
Is this even possible? or would i have to fire two queries.
SELECT n.*, AA.cnt
FROM nei_product_background_category c
INNER JOIN nei_backgrounds n ON n.background_id = c.background_id
INNER JOIN (
SELECT cc.product_id, COUNT(*) AS cnt
FROM nei_product_background_category cc
INNER JOIN nei_backgrounds nn ON nn.background_id = cc.background_id
GROUP BY cc.product_id
) AA ON c.product_id = AA.product_id
WHERE
c.product_id = 578
LIMIT 10
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.