469,612 Members | 1,674 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,612 developers. It's quick & easy.

How to filter duplicate entries in mysql?

170 100+
hey guys,

i'm stuck with finding a sql statement for filtering out duplicate entry

i got like thousands of entry but i would like to put a filter on so i can see all the duplicate entries

any idea how?
Jul 29 '08 #1
3 5705
r035198x
13,262 8TB
What's your table structure? Do you have at least one unique column in the table?
If you have it then the general structure of your query would be

Expand|Select|Wrap|Line Numbers
  1. select * from tableName where id not in (
  2. select min(id) from tableName group by col1, col2, ...)
This will give all the values with duplicate entries in col1, col2, ... but with different ids. It will also however not show the row with the minimum id.
Jul 29 '08 #2
poolboi
170 100+
What's your table structure? Do you have at least one unique column in the table?
If you have it then the general structure of your query would be

Expand|Select|Wrap|Line Numbers
  1. select * from tableName where id not in (
  2. select min(id) from tableName group by col1, col2, ...)
This will give all the values with duplicate entries in col1, col2, ... but with different ids. It will also however not show the row with the minimum id.
hm...u mean a primary key?
if so yeah i do have a unique column in my table
Jul 29 '08 #3
r035198x
13,262 8TB
hm...u mean a primary key?
if so yeah i do have a unique column in my table
Then substitute id with your key column and col1, col2, ... with the columns where the duplicated values are. As I said above it should give you all the duplicates omitting the row with the lowest id.
Jul 29 '08 #4

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

reply views Thread by harsh | last post: by
2 posts views Thread by Francesco Moi | last post: by
reply views Thread by Gary Lundquest | last post: by
1 post views Thread by Gary Lundquest | last post: by
7 posts views Thread by php_mysql_beginer911 | last post: by
reply views Thread by devrayhaan | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.