2012-05-29 23 views
1
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语句和休息ID一定的价值,从我自己的代码我如何可以插入使用select语句和一些额外的列

是有可能这样做在SQL表中的数据?

回答

0

可以是这样做的

insert into table (col1, col2, col3) 
select col1, 'static_value', col2 
from table2 

不要把你的价值不是来自未来选择后的选择。与选择混合。

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 
相关问题