How do i actually use if else with update in sql? I have tried a lot of ways but it still doesnt work.
This is the question:
Add a column called ‘Status’ to a relational table Customer and use one UPDATE statement to fill the column with information about the customer status. Mark ‘Y’ if the customers had placed any orders otherwise ‘X’ will be initialised.
I am stuck at the update part.
UPDATE CUSTOMER
IF(customer.customerID IN (SELECT customerID from invoice))
( set status = 'y' )
else
( set status = 'x' )
endif
where status is null;