I am trying to update the member row with the highest start date using:
UPDATE at_section_details a
SET a.sd_end_date = ?
, a.sd_details = ?
WHERE a.cd_id = ?
AND a.sd_start_date = (SELECT MAX(b.sd_start_date)
FROM at_section_details b
WHERE b.cd_id = ?)
The error message is: "SQLException in updateYMGroup: java.sql.SQLException: You can't specify target table 'a' for update in FROM clause
The table structure is: sd_id - primary key
cd_id - foreign key (many occurrences)
sd_section
sd_pack
sd_start_date
sd_end_date
sd_details
A member (cd_id) can start and then transfer out. The member can then transfer in again (new start date). When they transfer out we want to pick up the max start date to transfer out against.
Any assistance would be greatly appreciated.
Regards,
Glyn