MySQL Forums
Forum List  »  PHP

Delete table records if criteria met. (Not as easy as it sounds)
Posted by: Adam Jimp
Date: September 11, 2011 08:55AM

Help im really struggling.
I have hit a brick wall in my php mysql project, i hope somebody can help me.

I have a mysql table, here is a sample

id DATE TIME BRTOTAL BRNO LENDER LONO LOTOTAL
54 10/09/2011 14:09 - - >>4.7% 40 £12k
55 10/09/2011 14:09 - - 4.6% 31 £6k
.56 10/09/2011 14:09 - - 4.5% 106 £32k.
.57 10/09/2011 14:09 - - 4.4% 14 £15k.
59 11/09/2011 14:09 - - >>4.7% 40 £12k
60 11/09/2011 14:09 - - 4.6% 31 £6k
.61 11/09/2011 14:09 - - 4.5% 106 £32k.
.62 11/09/2011 14:09 - - 4.4% 14 £15k.
64 11/09/2011 15:09 - - >>4.7% 40 £12k
65 11/09/2011 15:09 - - 4.6% 31 £6k
.66 11/09/2011 15:09 - - 4.5% 106 £32k.
.67 11/09/2011 15:09 - - 4.4% 13 £13k.


Sorry if the layout has gone sqew but you get the idea.
This is what i need to do
If there is more than 2 records with the same date and time, delete the records with the same date and time except for 2 with the highest id
I have put .'s by the records that should be left, once the code has been run.

Could somebody help me try and put this into php script to delete records from mysql table.

Many Many Thanks



Edited 1 time(s). Last edit at 09/11/2011 08:56AM by Adam Jimp.

Options: ReplyQuote




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.