鑒于我有一堆查詢,例如
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;
如何避免每次運行這些查詢時都必須更新每個查詢中的 user_id?
理想情況下,類似
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;
我嘗試使用?和:userId
例如
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;
這提示我通過對話框輸入用戶 ID,這很好,除了我必須為每一行輸入 ir。
我希望能夠更新一個地方/輸入一次值。
DataGrip 可以做到這一點嗎?
uj5u.com熱心網友回復:
您可以使用${variable_name}語法為查詢只輸入一次值:
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;
轉載請註明出處,本文鏈接:https://www.uj5u.com/qianduan/480006.html
標籤:sql PostgreSQL 数据夹
