Help with SQL statement
Hello,
I am looking for help with a sql statement as below:
There a users table with following sample data:
id, user_type, user_uid, username, pass, firstname, lastname
1, 3, john1, jburg, jburg, John, Burg
2, 5, john1, jburg, jburg, John, Burg
3, 5, marta1, moliver, moliver, Marta, Oliver
The problem in the table is that I have records like #1 (id) and #2 (id) above where all data is same except user_type. These are duplicate records for us and we want to do away with the duplicates and keep only one record.
Further, like the in duplicate record above, we would like to keep the record which has lower value of user_type, which is 3 in the above case. So John's record above is duplicate and we want to do away all his records but keep the one with id #1 (since it has lower value of user_type)
Can anyone help?
Thanks