I have table that using this query:
SELECT id, channel
FROM (
SELECT s.id, c.sort, s.channel
FROM streams s, channels c
WHERE JSON_SEARCH(s.bouquet, 'one', 1) IS NOT NULL
AND JSON_SEARCH(c.bouquet, 'one', 1) IS NOT NULL
AND JSON_SEARCH(c.sort, 'one', s.id) IS NOT NULL
UNION
SELECT m.marker, c.sort, m.channel
FROM markers m, channels c, streams s
WHERE JSON_SEARCH(m.bouquet, 'one', 1) IS NOT NULL
AND JSON_SEARCH(c.bouquet, 'one', 1) IS NOT NULL
AND JSON_SEARCH(c.sort, 'one', m.marker) IS NOT NULL) ch
ORDER BY LOCATE(CONCAT('"', id, '"'), sort);
Return this table:
+----+----------+
| id | channel |
+----+----------+
| m2 | AAA |
| 1 | CC_DDD |
| 2 | DD_EEE |
| 11 | FF_GGG |
| m4 | BBB |
| m3 | CCC |
| m5 | MMM |
| m1 | GGGG |
+----+----------+
Now i need to count id field but only integer values, so i try to add:
SELECT id, channel, COUNT(id) AS values...
But i get this error:
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'values FROM
(SELECT s.id, c.sort, s.channel FROM streams s, channels c WHERE JS' at line 1
So i need to get this:
+----+----------+--------+
| id | channel | values |
+----+----------+--------+
| m2 | AAA | 3 |
| 1 | CC_DDD | |
| 2 | DD_EEE | |
| 11 | FF_GGG | |
| m4 | BBB | |
| m3 | CCC | |
| m5 | MMM | |
| m1 | GGGG | |
+----+----------+--------+
So the point is that i need to count only integer values and NOT values that begins with m (m2,m4,m3,m5,m1).
Is this possible with this single query to return count values or do i need to run two query at same time?