Question

Does dynamic SQL work in phpMyAdmin?

I tried the most basic examples from http://www.youtube.com/watch?v=MiAwOoelu9k

For instance, each of these throws an error (tried separately):
EXEC ('SELECT data FROM table')
EXEC sp_executesql N'SELECT data FROM table'

Was it helpful?

Solution

I found the answer in multiple Stackoverflow streams (listed below). It depends on the version of phpMyAdmin, which needs to be v3.5.2.2 or higher. This is because Dyanamic SQL is part of a STORED PROCEDURE. Older versions of phpMyAdmin allow you to CREATE a STORED PROCEDURE, but the ability to CALL a STORED PROCEDURE within phpMyAdmin requires version 3.5.2.2 or higher. (Source: is it possible to run a stored procedure from within phpmyadmin 3.4.10.1?)

For those using an older version of phpMyAdmin who need to use Dynamic SQL, an alternative is Workbench (http://www.mysql.com/products/workbench/)

For those using phpMyAdmin version 3.5.2.2 or higher, to CREATE and CALL a STORED PROCEDURE, here are posts of other users:

How to write a stored procedure using phpmyadmin and how to use it through php? How to write a stored procedure using phpmyadmin and how to use it through php?

MySQL procedure not getting created/working using phpmyadmin mysql procedure not getting created/working using phpmyadmin

How do I view my stored procedures in phpMyAdmin? How do I view my stored procedures in phpMyAdmin?

I created several stored procedures in phpmyadmin, how to call them using an sql query? I created several stored procedures in phpmyadmin, how to call them using an sql query?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top