Jump to content

Delete records from mysql if criteria met (harder than it seems)


Directlinq

Recommended Posts

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

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.