I am a Newbee using MySQL Workbench. I have a table Called requests. It has a column called STATUS and another called EXPIREDDATE. I want to create a Stored procedure that Inputs the text “Exipred” into the column STATUS if the date in EXPIREDDATE exceeds Todays date. The begining of the code is below. Thanks.
CREATE PROCEDURE `Add Expired` ( IF expireddate => todays date THEN status = "expired") BEGIN END
Advertisement
Answer
Inputs the text “Expired” in to a column
A
if the date in columnB
exceeds Todays date
You are describing an update
statement with filtering:
update mytable set a = 'expired' where b > current_date
You can easily turn this to a stored procedure – although it wouldn’t be very helpful (you can just run the query).