-----------------------------
id | category_id | title |
-----------------------------
1 | 1 | title1 |
----------------------------
2 | 2 | title1 |
----------------------------
3 | 3 | title3 |
SELECT * FROM pages WHERE title IN (SELECT title FROM pages GROUP BY title HAVING COUNT(*)>1) ORDER BY title
INSERT INTO PAGES (ID, CATEGORY_ID, TITLE) VALUES (4, 3, 'title3');
SELECT ID,
CATEGORY_ID,
TITLE
FROM PAGES
WHERE TITLE IN (SELECT TITLE FROM PAGES GROUP BY TITLE HAVING COUNT(*)>1)
GROUP BY TITLE,
CATEGORY_ID
HAVING COUNT(*)=1;