欧米茄海马皮表带:SQL语句问题

来源:百度文库 编辑:高校问答 时间:2024/05/06 14:02:18
insert into 表一(字段二,字段四) values('select 字段一 from 表一 where 字段二='XXXXXX'','XXXXXX')
也就是往表一中插入两个字段的数据,第一个为SQL查询出的,第二个是人为了,请问如何添写。谢谢
不知道我写清楚没,呵呵
id name price
1 苹果 100
2 香蕉 200
insert into shuiguo(name,price) values('select name from shuiguo where name='苹果'','100')
这样,吼吼~~~这回不知道大家能看懂不

要用insert into .. select .. 语句

insert into shuiguo(name,price) select name,'100' from shuiguo where name='苹果'

如果太麻烦,你就直接写两个查询不就行了?
先 'select 字段一 from 表一 where 字段二='XXXXXX'
获取你的 字段一变量
然后直接
insert into 表一(字段二,字段四) values(字段一变量,第二个变量)就可以了啊

你是不是想批量插入啊?
可以用
insert into Table1 (Field1,Field2,……) values (select Field3 from Table where Field4=Value1 or Field5=Value2 [or ....])

好象是这样的!

试试这样写:
insert into 表一(字段二,字段四) EXEC('select 字段一,字段二 from 表一 where 字段二=''XXXXXX''')

不知道你也的什么意思,但肯定是错的