472,133 Members | 974 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,133 software developers and data experts.

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 5845
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 leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.