I am reading the book Sams Teach Yourself SQL in 10 Minutes (Fifth Edition)
to learn SQL.
I cam across the chapter on Cursors
and tried to execute the below query in phpmyadmin
DECLARE CustCursor CURSOR
FOR
SELECT * FROM Customers
WHERE cust_email IS NULL;
And got this error:
Unrecognized statement type. (near "DECLARE" at position 0)
I tried searching a lot and even question on StackOverflow but couldn't find any answer which could solve the issue. Some talks were regarding Delimiters but I couldn't solve the issue and just learnt that DELIMITER is not a MySQL command.
.
CodePudding user response:
The problem is not with PhpMyAdmin, but the syntax of your sql command.
Cursors only can be declared inside a procedure. You cant write a simple select with cursor and execute, this will throw and error.
Take a look on the thread: MySql Cursor - Creating a procedure OR Mysql Stored procedure with cursor