Save typing effort for complex MySQL queries with custom variables or procedures

To save time and because it’s not that smart to repeatedly retype the same things multiple times, you can user custom variables in MySQL like that:

You first have to run the SET query. Afterwards the variables are available for the whole session. Then you can fire the SELECT with the custom variables.

Another possibility would be the usage of a MySQL procedure:

This procedure could be called like that:

By the way, these queries are getting the product name, the short description and the description out of a Magento database.

Leave a Reply

Your email address will not be published. Required fields are marked *

 

This site uses Akismet to reduce spam. Learn how your comment data is processed.