0
UPDATE Tickets
    SET Price = 1.13 * Price
FROM Tickets t
JOIN Flights f ON t.FlightId = f.Id
WHERE f.Destination = 'Carlsbad'

UPDATE Tickets
    SET t.Price = 1.13 * t.Price
FROM Tickets t
JOIN Flights f ON t.FlightId = f.Id
WHERE f.Destination = 'Carlsbad'

The first code is working perfectly fine, but when I try the second, I get the error

The multi-part identifier "t.Price" could not be bound.

What's the problem? I think it's more clear the second way.

1

1 Answer 1

2
UPDATE t
    SET t.Price = 1.13 * t.Price
FROM Tickets t
JOIN Flights f ON t.FlightId = f.Id
WHERE f.Destination = 'Carlsbad'

You need to use t (table alias)

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you! I didn't know that.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.