insert into
[Client].[generalcontact_info]([userid], [first_name], [last_name],
[email], [mobile],
[country], [state], [city], [address],
[Case_id], [contact_type], [query])
select
[userid], [first_name], [last_name],
[email], [mobile],
[country], [state], [city], [address]
from
[Admin].[basicinfo]
where
[userid] = 100003
,'4521r521','Inside','what is my password'
我从select语句中获取一些值,并从我自己的代码中获取rest id
有可能吗?
答案 0 :(得分:1)
是的当然是可能的 - 用于插入的SELECT
可以在其值列表中同时包含列和“常量”:
insert into
[Client].[generalcontact_info]([userid], [first_name], [last_name],
[email], [mobile],
[country], [state], [city], [address],
[Case_id], [contact_type], [query])
select
[userid], [first_name], [last_name],
[email], [mobile],
[country], [state], [city], [address],
'4521r521', 'Inside', 'what is my password'
from
[Admin].[basicinfo]
where
[userid] = 100003
答案 1 :(得分:0)
你可以这样做
insert into table (col1, col2, col3)
select col1, 'static_value', col2
from table2
在选择之后,不要让您的值不来自选择。将它与选择混合。