SQl command

Could someone quickly tell me what the command in sql to change all the owner ids of tents and to delete all the dead bodies

Thanks
 
Update the owners of tents:

Code:
UPDATE instance_deployable d LEFT JOIN (
SELECT DISTINCT d.owner_id, s.unique_id
FROM instance_deployable d
LEFT JOIN survivor s ON s.id = d.owner_id
WHERE s.is_dead =1
) AS dead ON dead.owner_id = d.owner_id
LEFT JOIN survivor live ON live.unique_id = dead.unique_id
SET d.owner_id = live.id WHERE live.is_dead =0


Delete dead characters:

Code:
WHERE is_dead = 1 AND id NOT IN (SELECT DISTINCT owner_id FROM instance_deployable);
 
Back
Top