Jump to content

Deletinh Rows in mysql


turtleman8605

Recommended Posts

I am working on a script to clean out a bad database table of users that has multiple entries for each user (identified by email) I am trying to use SELECT DISTINCT (email), first_name, .... In other words, email is the only field that is necessarily unique and I want to keep only one row for each email address. How can I do this so that it allows for the other fields to be duplicates?

Link to comment
https://forums.phpfreaks.com/topic/108419-deletinh-rows-in-mysql/
Share on other sites

OK, sorry about the lack of details. The way that I want to choose which one to keep is by a the `last_login` field. If the user has never logged in it will show 00-00-00 00:00:00 (Datetime field). If it is anything other than that, then the user has logged in using this row's information and it is possible that they have changed data, so I don't want to lose this one. However, if all `last_login` fields are 0, then it doesn't matter.

 

The duplicate rows however do have unique `id` fields.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.