I need to be able to add a set of values into a table every time a new user is added into my system.
When the user is added, I want to look into my 'Tags' table, and insert a new entry into the 'Tag_Score' table for each of the IDs in the 'Tags' table.
I tried the following based on something i found online but although the logic seems sound, it doesn't seem to be working
DECLARE @LoopVar INTEGER
SET @LoopVar = ( SELECT MIN(Tag_Score.T_ID)
FROM Tags ) WHILE @LoopVar IS NOT NULL
BEGIN
INSERT INTO `a3360218_DD`.`Tag_Score` (
`A_ID` ,
`T_ID` ,
`Score` ,
`Visits`
)
VALUES (
'" . $accountID . "', @LoopVar , '0', '0'
)
SET @LoopVar = ( SELECT MIN(Tag_Score.T_ID)
FROM TheTable
WHERE @LoopVar < T_ID )
END
The error given is:
#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 'WHILE @LoopVar IS NOT NULL
BEGIN
INSERT INTO `a3360218_DD`.`Tag_Score` (
' at line 2
Thanks in advance
Matt