Given this query :
SELECT cur.`id`
FROM `current` AS cur
LEFT OUTER JOIN (
SELECT MAX(EndDay_id.id) as id, EndDay_id.server_id
FROM current as EndDay_id
GROUP BY server_id, gameday
) AS EndDay
ON cur.id = EndDay.id
WHERE EndDay.id IS null
How do I delete the rows from table 'current' whose id field is in the resultset of previous query ?
Try this
DELETE cur FROM `current` AS cur
LEFT OUTER JOIN (
SELECT MAX(EndDay_id.id) as id, EndDay_id.server_id
FROM current as EndDay_id
GROUP BY server_id, gameday
) AS EndDay
ON cur.id = EndDay.id
WHERE EndDay.id IS null
I tested it and this should work: http://sqlfiddle.com/#!2/a47c81
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments