I have the following query which returns data with a limit of 5.
SELECT a.* FROM (
SELECT category, description, price, date_added, datetime_created
FROM vc_expense e1
WHERE trip_id=:trip_id AND description LIKE :search
UNION ALL
SELECT category, description, NULL, NULL, NULL
FROM vc_expense_default e2
WHERE description LIKE :search
) AS a
GROUP BY description, price
ORDER BY CASE
WHEN price IS NOT NULL THEN 1
WHEN description LIKE :search_start THEN 2
WHEN description LIKE :search THEN 3
ELSE 4
END, datetime_created DESC, date_added DESC
LIMIT 5
Everything works as intended, but I want to also include how many items was also returned before the LIMIT. Something like this would be good:
{
count: 32,
data: [items, limited to 5]
}
I have tried the following with no luck:
SELECT COUNT(a.*) AS count, a.* AS data FROM (