mysql – 执行查询时出错

我正在尝试运行查询.但它给出了一个错误.

    Query: UPDATE b SET b.Booking_Date = CURDATE() ,b.Departure_City = 'test', b.Arrival_City = 'test', b.Departure_DateAndTime = CURDATE()...

    Error Code: 1064
    You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'FROM Booking b inner join Booking_Type bt 
    on b.Booking_Id = bt.Booking_Id in' at line 4

查询:

    UPDATE b SET b.Booking_Date = CURDATE() ,b.Departure_City = 'test', b.Arrival_City = 'test',
                b.Departure_DateAndTime = CURDATE(), b.No_Of_Tickets = '5',
                b.Is_Active = 1, b.Modified_Date = CURDATE(), b.Modified_By = 123   
        FROM Booking b INNER JOIN Booking_Type bt 
        ON b.Booking_Id = bt.Booking_Id INNER JOIN Ticket t 
        ON t.Booking_Type_Id =  bt.Booking_Type_Id WHERE t.Ticket_No = 't001'

最佳答案 语法错误,使用join更新的正确语法如下

update Booking b
INNER JOIN Booking_Type bt ON bt.Booking_Id = b.Booking_Id
INNER JOIN Ticket t ON t.Booking_Type_Id =  bt.Booking_Type_Id
SET
b.Booking_Date = CURDATE(),
b.Departure_City = 'test',
b.Arrival_City = 'test',
b.Departure_DateAndTime = CURDATE(), 
b.No_Of_Tickets = '5',
b.Is_Active = 1, 
b.Modified_Date = CURDATE(), 
b.Modified_By = 123   
WHERE t.Ticket_No = 't001'
点赞