brihol44
asked on
how can I delete all records with the same date (by day, no time) that also has the same value for 1 other column.
how can I delete all records with the same date (by day, no time because the time might be different. Actual date value I have: 2013-12-08 15:33:20) that also has the same value for 1 other column. I'm getting duplicates and I want to run that sql command afterwards to fix the issue.
Thanks!
Thanks!
Oh. The data inside the string should conform to the format that you're using.
Kent
Kent
ASKER
ok, I need to dynamically pull the date and something value and have mysql work for me not statically place 'something' or the date individually in the column. So if it's the date value wouldn't it be...
DELETE from {mytable}
WHERE date (column) = '%Y-%m-%d'
AND othercolumn = 'something';
but wouldn't this statement also delete all records?
DELETE from {mytable}
WHERE date (column) = '%Y-%m-%d'
AND othercolumn = 'something';
but wouldn't this statement also delete all records?
ASKER
to be clear I just want to leave 1 record but delete all other duplicate records with the same date and othercolumn value = the same.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Ah. Even easier. (And you can use the primary_key in most any filtered delete.) From the earlier description it appeared that the data didn't contain a primary key.
Kent
Kent
ASKER
I guess i wasn't clear enough but the suggestion got me thinking in the right direction.
Try this:
Open in new window
Good Luck,
Kent