How to delete rows from a table when we're joining and return data?

Very simple indeed, but you do need to include the other WHERE clause as well:

DELETE FROM batch bp
USING  sender_log sl
WHERE  bp.log_id = sl.id
AND    bp.protocol = 'someprotocol'
RETURNING bp.*, sl.*;

And to actually return what your question outlines, you need to include both tables in the RETURNING clause.


Very simple indeed:

DELETE FROM batch bp
USING sender_log sl
WHERE bp.log_id = sl.id
RETURNING sl.packet

;-)