MySQL Forums
Forum List  »  PHP

Help with SQL statement
Posted by: Kshitij Ahuja
Date: February 13, 2014 03:39AM

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

Options: ReplyQuote


Subject
Written By
Posted
Help with SQL statement
February 13, 2014 03:39AM
February 13, 2014 11:25AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.