How to use SQL Parameters with your import?
When using a custom SQL query with Coefficient, you can now add a Parameter that will dynamically point to a specific cell/range of cells/values in your sheet. This will allow you to create complex queries + Parameters that allow your teammates to enter the needed data on a cell for the import to run. How cool is that! 🤓
SQL Parameters can be used with any Coefficient Integration that has custom SQL queries as an import option. These include MySQL, PostgreSQL, MS SQL, Snowflake, RedShift, etc.
(This example will use MySQL and set the value for the “film.release_year” column using the SQL Parameter feature. The goal is to pull a list of movies based on the value we set for cell B1 in a new tab.)
Select “Import from…” **from the main menu.
Select MySQL and choose “Custom SQL Query”.
The Data Preview window will appear. You will see all your previously created parameters listed but you can always add a new one.
NOTE: The parameters listed are other parameters in the current spreadsheet and are not shared across spreadsheets.
Click the “Add another parameter” button to add your new SQL Parameter*.* Each parameter name must be UNIQUE. You will need to manually enter the cell/range of cells referenced in your Sheet. The format of your cell/range should be ‘<Name of your sheet>’!<cell or range of cells>”. (Example: “Import1!A1” or “Import1!A1:D1”)’
Add your query to this import. If you are using the parameter, you MUST include “{{” before and “}}” after for it to be valid. Click the “Refresh Preview” button to see how your data is shown.
<aside> 💡 ProTip: You can start typing “{{” and a list of available variables should appear so you do not have to copy and paste it. Make sure you place “}}” at the end.
</aside>
NOTE: The system should automatically list your parameters for easy selection once you typed in “{{”.