Is there an efficient way to get the list of affected row IDs (not the # of affected rows via PHP's mysql_affected_rows(), but the actual row ids that were affected) from an UPDATE or DELETE query in mysql?
In postgresql, there is a RETURNING clause within UPDATE/DELETE queries that can be used to specify values from the affected rows that are returned.
In mysql, the 'brute force' way of getting the affected rows seem to be:
1. Acquire READ LOCK.
2. SELECT to with the WHERE condition of the UPDATE/DELETE query to get the affected row ids.
3. UPDATE/DELETE.
4. RELEASE LOCK.
The above way seems very inefficient. Is there a more efficient way to get the affected row ids in mysql?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…