9

In DataGrip, how can I pass parameters to SQL query? Say I have a query:

select * from table where date >= ?

Then how can I bind the variable here? When I open the parameters pane, i.e. click the P button here.

enter image description here

I see

No parameters present

Or:

enter image description here

Where should I set the parameter value?

Psidom
  • 209,562
  • 33
  • 339
  • 356

2 Answers2

9

You can also use pre-defined parameters to easily bind them into a query, more data can be found in this link: https://www.jetbrains.com/help/datagrip/settings-tools-database-user-parameters.html

i.e if you need to replace one variable in more than one place, do it with :var_name

And it will replace all its occurrences in the query.

Select x from y where z = (:val) and w = (:val)

Neil
  • 7,482
  • 6
  • 50
  • 56
Adi Oz
  • 257
  • 1
  • 4
  • 8
6

Just run it via Ctrl+Enter! enter image description here The parameter pop-up will appear.

moscas
  • 9,064
  • 36
  • 42