Search code examples
mysqleditorworkbench

MySql Workbench parameter placeholders


While browsing through the available snippets in the workbench I came across pieces of code with sort of formal parameters and/or placeholders, in the form of <{[identifier]}>, which are particularly highlighted in the editor .

Are they simple formal placeholders or do they have some other additional use?


Solution

  • Yes, those are placeholders and they are designed to make your snippets less specific and more general purpose. You can press CTRL+SHIFT+? to automatically move to the next placeholder to fill in the specific values you need.

    For example:

        /* find total sales for each product, including only products that have total sales exceeding a specified amount */
        SELECT
            Products.ProductName,
            SUM(Orders.Quantity) AS TotalSales
        FROM
            Products
        INNER JOIN Orders ON Products.ProductID = Orders.ProductID
        GROUP BY
            Products.ProductName
        HAVING
            SUM(Orders.Quantity) > <{[minimum_order_amount]}>
    

    You can load this snippet into the editor, and then press CTRL+SHIFT+? to automatically move to the variable that you might want to edit. You can have as many of these placeholders as you like.

    Note: the shortcut key combo only works forward. Once you are below a placeholder, the shortcut won't find your placeholders. So if you paste a snippet, you'll have to move to the top of your snippet (press CTRL+HOME, for example).