Chapter 36. Dynamic SQL with Prepared Statement

36.1 Introduction

Since version 5.0, MySQL has supported prepared SQL statements (prepared SQL), sometimes called dynamic SQL. The opposite of dynamic SQL is, as might be expected, static SQL. This book has described static SQL so far. Each SQL statement is included in its entirety in a program or in a stored procedure or function or is entered with query tools such MySQL Query Browser, SQLyog, and WinSQL. The SQL statements are not built dynamically. For example, if we want to develop a stored procedure that has a table name as an input parameter and removes the specified table when the procedure is called, this is difficult to solve with static SQL. Of course, we could include a long and extensive ...

Get SQL for MySQL Developers: A Comprehensive Tutorial and Reference now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.