I'm having some trouble with a MySQL query I'm writing. I'd like to get a count of the number of rows that my query is returning without actually returning the rows and then using mysql_num_rows or the like.
My query is as follows:
SELECT COUNT(l.product_number_language) as counts, l.id, l.product_number, l.language, l.product_number_language
FROM bs_products_languages l
LEFT JOIN bs_products p ON (l.product_number_language = p.product_number)
WHERE l.product_number = 'C4164'
AND l.active='Y'
AND p.active='Y'
GROUP BY l.language
The following is what is being returned:
And what I really want is simply a count of these rows, so in this case 3.
Select count(*)
From
(
SELECT COUNT(l.product_number_language) as counts, l.id, l.product_number,
l.language, l.product_number_language
FROM bs_products_languages l
LEFT JOIN bs_products p ON (l.product_number_language = p.product_number)
WHERE l.product_number = 'C4164'
AND l.active='Y'
AND p.active='Y'
GROUP BY l.language
) as t
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With