[英]Complicated SQL query for Jenkins
I am trying to create a Jenkins script using a SQL query with variables that are parameters in Jenkins.我正在尝试使用 SQL 查询创建一个 Jenkins 脚本,其中变量是 Jenkins 中的参数。 I need to use an insert using a select statement, a variable, and a static number.我需要使用一个 select 语句、一个变量和一个静态数字来使用插入。 How can I create this query?如何创建此查询?
I have the select statement that will need to be used in the insert working:我有需要在插入工作中使用的 select 语句:
SELECT uid FROM client_template.user
WHERE TYPE = 0 AND ACTIVE = 1
AND uid NOT IN (45,58,1331,1793,1807,2713);
However, I am unsure how to fit the above query into one that will work like this (Values 1234 & 1 -- correspond to did & urid):但是,我不确定如何将上述查询适合这样的查询(值 1234 & 1 -- 对应于 did & urid):
INSERT INTO client_schema.user_role_roles (did, urid, uid)
VALUES (1234, 1)
SELECT uid FROM client_template.user
WHERE TYPE = 0 AND ACTIVE = 1 AND uid NOT IN (45,58,1331,1793,1807,2713);
Your question isn't totally clear, but if you are trying to use the select statement to select the uid
to use as the third parameter in your INSERT
then try:您的问题并不完全清楚,但是如果您尝试使用 select 语句来选择要用作INSERT
第三个参数的uid
,请尝试:
INSERT INTO client_template.user_role_roles (did, urid, uid)
SELECT TOP 1 1234, 1, uid FROM client_template.user
WHERE TYPE = 0 AND ACTIVE = 1 AND uid NOT IN (45,58,1331,1793,1807,2713);
Note that your static values 1234
and 1
are simply listed as constants in your SELECT
subquery.请注意,您的静态值1234
和1
在您的SELECT
子查询中只是作为常量列出。
You should add the literal/constant value in the corresponding position in select您应该在 select 中的相应位置添加文字/常量值
INSERT INTO client_schema.user_role_roles (did, urid, uid)
SELECT 1234, 1, uid
FROM client_template.user
WHERE TYPE = 0
AND ACTIVE = 1
AND uid NOT IN (45,58,1331,1793,1807,2713);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.