Hello,
I'm trying to create some loops inside my sql statements for some data migration. I have setup the following SQL statement to test out my syntax but keep recieving errors. Here are the ones I tried:
And:Code:USE favoriteagent; SELECT @totrows := COUNT(Customerid) FROM agents; SET @count := 0; REPEAT SELECT * FROM agents WHERE (Customerid = @count); SET @count := (@count -1); UNTIL (@count := 0) END REPEAT;
Everytime I recieve the following errors:Code:USE favoriteagent; SELECT @totrows := COUNT(Customerid) FROM agents; SET @count := 0; WHILE (@count < @totrows) DO SELECT * FROM agents WHERE (Customerid = @count); SET @count := (@count -1); END WHILE;
(using repeat)
#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 'REPEAT
SELECT * FROM agents WHERE (Customerid = @count)' at line 1
(useing while)
#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 (@count < @totrows) DO
SELECT * FROM agents WHERE (Customerid = @count)' at line 1
How I do a loop?
Thanks in advance.


LinkBack URL
About LinkBacks





Reply With Quote

Bookmarks
Algorithms and Data Structures
Java tutorials
Algorithms Forum