Podrías usar union all
para generar una sola columna con todos los ID y luego contarlos:
SELECT id, COUNT(*)
FROM (SELECT id1 AS id FROM mytable
UNION ALL
SELECT id2 AS id FROM mytable) t
GROUP BY id
Podrías usar union all
para generar una sola columna con todos los ID y luego contarlos:
SELECT id, COUNT(*)
FROM (SELECT id1 AS id FROM mytable
UNION ALL
SELECT id2 AS id FROM mytable) t
GROUP BY id