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.

Dale K
  • 25,246
  • 15
  • 42
  • 71
Katherine
  • 397
  • 2
  • 17
  • Does this answer your question? [SQL update query using joins](https://stackoverflow.com/questions/982919/sql-update-query-using-joins) – forpas Feb 22 '22 at 19:51

1 Answers1

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)

Nafis Islam
  • 1,483
  • 1
  • 14
  • 34