4

I am trying to run a query. But it gives a error.

    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

Query:

    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'

1 Answer 1

2

The syntax is wrong, the correct syntax for update with join would be as

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'
Sign up to request clarification or add additional context in comments.

Comments

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.