Potresti usare union all
per generare una singola colonna con tutti gli ID, e poi contarli:
SELECT id, COUNT(*)
FROM (SELECT id1 AS id FROM mytable
UNION ALL
SELECT id2 AS id FROM mytable) t
GROUP BY id
Potresti usare union all
per generare una singola colonna con tutti gli ID, e poi contarli:
SELECT id, COUNT(*)
FROM (SELECT id1 AS id FROM mytable
UNION ALL
SELECT id2 AS id FROM mytable) t
GROUP BY id