I have:
#create a table to store user data
CREATE TABLE IF NOT EXISTS user(
userID int NOT NULL AUTO_INCREMENT PRIMARY KEY,
lastName VARCHAR(32) NOT NULL,
firstName VARCHAR(32) NOT NULL,
gender VARCHAR(16) NOT NULL,
DOB VARCHAR(16) NOT NULL,
familySize INT,
);
#create a table to store user their remaining fruits/vegetable points
CREATE TABLE IF NOT EXISTS fruitsVegetablesPoints(
userID int,
remainingFruitsVegetablesPoints INT
);
#create a table to store user their remaining grain points
CREATE TABLE IF NOT EXISTS grainsPoints(
userID int,
remainingGrainsPoints INT
);
#create a table to store user their remaining protein points
CREATE TABLE IF NOT EXISTS proteinDairyPoints(
userID int,
remainingProteinDairyPoints INT
);
###############################################
#Need to know how to reset points every month
###############################################
CREATE EVENT resetPoints ON SCHEDULE
EVERY 1 MONTH
STARTS '2020-04-30 19:58:00'
ON COMPLETION PRESERVE ENABLE
DO
BEGIN
UPDATE proteinDairyPoints
SET remainingProteinDairyPoints = (select familySize from user where userID = 1) * 3;
END;
I get an error in 'SET remainingProteinDairyPoints = (select familySize from user where userID = 1) * 3;' I'm trying to reset points every first day of the month. The points are based on the user's family size. How can I access userid's family size in SET remainingProteinDairyPoints?