Skip to content

Instantly share code, notes, and snippets.

@AlexMcowkin
Created August 8, 2018 14:49
Show Gist options
  • Save AlexMcowkin/ab112ddac443e06ddaac9b053f38a9aa to your computer and use it in GitHub Desktop.
Save AlexMcowkin/ab112ddac443e06ddaac9b053f38a9aa to your computer and use it in GitHub Desktop.
SQL: выбор не уникальных (повторяющихся) значений из таблицы
CREATE TABLE `post` (
`id` int(11) NOT NULL,
`name` varchar(100) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
//----------------------------------------
SELECT id, name FROM post WHERE id IN (SELECT id FROM post GROUP BY id having count(id) > 1) ORDER BY id;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment