Databases Reference
In-Depth Information
Manipulating bookmarks
Sometimes, we may just want to ascertain the contents of a bookmark. This is
done by choosing a bookmark and selecting View only . The query is then displayed
and we have the opportunity of reworking its contents. By doing so, we would be
editing a copy of the original bookmarked query. To keep this new, edited query,
we can save it as a bookmark. Again, this will create another bookmark even if we
choose the same bookmark label, unless we explicitly ask for the original bookmark
to be replaced.
A bookmark can be erased with the Delete option. There is no confirmation dialog to
confirm the deletion of the bookmark. We should now proceed with the deletion of
our book bookmark.
Passing a parameter to a bookmark
If we look again at the irst bookmark we created (inding all topic for author 1 ), we
realize that although it's useful, it's limited to finding just one author—always the
same one.
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 us say we want to ind all the topic for a given author when we don't know the
author's id . We first enter the following query:
SELECT author.name, author.id, book.title
FROM book, author
WHERE book.author_id = author.id
/* AND author.name LIKE '%[VARIABLE]%' */
 
Search WWH ::




Custom Search