O'Reilly logo

Mastering phpMyAdmin 3.1 for Effective MySQL Management by Marc Delisle

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Bookmark parameters

If we look again at the first bookmark we created (finding all books for author 1), we realize that although it is useful, it is limited to finding the same author.

Special query syntax enables the passing of parameters to bookmarks. This syntax uses the fact that SQL comments enclosed within /* and */ are ignored by MySQL. If the /*[VARIABLE]*/ construct exists somewhere in the query, it will be expanded at execution time with the value provided when recalling the bookmark.

Creating a parameterized bookmark

Let's say we want to find all the books for a given author when we don't know the author's name. We first enter the following query:

SELECT author.name, author.id, book.title FROM book, author WHERE book.author_id = author.id ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required