Given I have a bunch of queries E.g.
delete from permissions where user_id = 9845 and project_id =2;
delete from users_projects where user_id = 9845 and project_id =2;
delete from users where id = 9845 and project_id =2;
How can I avoid having to update the user_id in each query each time I run these?
Ideally, something like
var userId = 9845
delete from permissions where user_id = userId and project_id =2;
delete from users_projects where user_id = userId and project_id =2;
delete from users where id = userId and project_id =2;
I tried using ?
and :userId
E.g.
delete from permissions where user_id = :userId and project_id =2;
delete from users_projects where user_id = :userId and project_id =2;
delete from users where id = :userId and project_id =2;
This prompts me to enter a User Id via a dialog, which is fine, except I have to enter ir for each row.
I want to be able to update one place / enter the value once.
Is this possible with DataGrip?
CodePudding user response:
You can use ${variable_name}
syntax to enter a value only once for queries:
delete from permissions where user_id = ${userId} and project_id =2;
delete from users_projects where user_id = ${userId} and project_id =2;
delete from users where id = ${userId} and project_id =2;