I have a query that gets the number of rows returned within selecting records, my query looks like this:
SELECT rec.record_id,
rec.record_title,
usr.user_id,
usr.username,
(
SELECT COUNT(DISTINCT rec.record_id)
FROM records rec
WHERE rec.record_title LIKE '%random%'
GROUP BY rec.record_id
) AS total_records
FROM
(
records rec
INNER JOIN members usr
)
WHERE rec.record_title LIKE '%random%'
GROUP BY rec.record_id
LIMIT 0, 25
I need to be able to return the number of records in the total_records subquery using the maximum number found when it includes GROUP BY and has multiple records returned which I only need one and that should be the number of records found within the subquery.
How can you get the total records in the subquery by finding the maximum number found or add the multiple records together to make a number of records found.
Maybe this is what you want? If not, please clarify your question, and I’ll try again.