I'm trying to prevent deadlocks in my code because i may use both in different parts of my project.
Do they lock rows in the same order?
Nested
select * from `carts` where `carts`.`user_id` = ? and exists ( select * from `cart_items` where `carts`.`id` = `cart_items`.`cart_id` for update ) for update
Separate
select * from `carts` where `carts`.`user_id` = ? for update
select * from `cart_items` where `cart_id` = ? for update