1

The original idea for my function was to have the date in my schedule table be compared to today's date in an if statement, and if the date in the table is past the date of today it would move the row of data from the schedule table to the past_shows table.

this is what i have tried so far,

DELIMITER //
CREATE FUNCTION pastShow (
showID INT,
date_time DATETIME 
)
BEGIN
// if condition
IF (date_time > DATE)
  THEN
    INSERT showID, date_time INTO past_shows From schedule
END IF;
END; //
DELIMITER ;
Stefan Wuebbe
  • 2,109
  • 5
  • 17
  • 28
Sophia-l-S
  • 11
  • 2
  • 1
    I suggest you reread the manual and resolve the syntax errors. https://dev.mysql.com/doc/refman/8.0/en/create-procedure.html and review what sql functions are for https://stackoverflow.com/questions/1179758/function-vs-stored-procedure-in-sql-server – P.Salmon Dec 12 '22 at 15:47
  • It seems really unnecessary to have a separate table to store past events, when this is a very simply query - `SELECT * FROM schedule WHERE date_time < NOW()` - if you really need the `past_shows` object, then you could always [create a view for this](https://dbfiddle.uk/EM-L00qA) – GarethD Dec 12 '22 at 15:53

0 Answers0