Updating a shopping cart
Next, for your practice, use a single-partition batch to add another movie into the same shopping cart and update the running total.
✅ Update the shopping cart:
Solution
BEGIN BATCH
INSERT INTO shopping_cart
(cart_id, title, year, price, user)
VALUES (b7255608-4a42-4829-9b84-a355e0e5100d,
'Edward Scissorhands', 1990, 3.99,
'joe@datastax.com');
UPDATE shopping_cart SET total = 6.97
WHERE cart_id = b7255608-4a42-4829-9b84-a355e0e5100d
IF total = 2.98;
APPLY BATCH;
✅ Retrieve the shopping cart:
Solution
SELECT total, price, title, year
FROM shopping_cart
WHERE cart_id = b7255608-4a42-4829-9b84-a355e0e5100d;