比如我的产品表里面有一下内容:
id name desri
1 abc fsfs
2 bcd asdf
3 def gfhj
4 qwe fdfg
5 wer dfgh
如果我要把以上产品表的内容里面的(id,name)这两个字段的全部记录添加到
报价产品表里面去,还有如果发现id号重复,就别插入,请问这个sql语句该怎么写??
是sql语句,不要用到delphi里面的循环
谢谢!!
补充一点:
报价产品表的字段结构是
id name ,bj,memo
id name desri
1 abc fsfs
2 bcd asdf
3 def gfhj
4 qwe fdfg
5 wer dfgh
如果我要把以上产品表的内容里面的(id,name)这两个字段的全部记录添加到
报价产品表里面去,还有如果发现id号重复,就别插入,请问这个sql语句该怎么写??
是sql语句,不要用到delphi里面的循环
谢谢!!
补充一点:
报价产品表的字段结构是
id name ,bj,memo
select id,name from 产品表 where
产品表.id not in (select id from 报价产品表)
select id,name from 产品表 where
产品表.id not in (select id from 报价产品表)
先给50分,
但还有个问题,如果我想在插入id,name的同时,把报价产品里面的bj赋为0,
把memo赋为"备注",该怎么办呢????
select 产品表.id, name, 0, '备注' from 产品表
right outer join 报价产品表 on 产品表.id = 报价产品表 .id
where 产品表.id is null
把memo赋为"备注"?你说的0和"备注"都是这样的常量么?还是不同的记录有不同的内容??要是常量的话:insert into 报价产品表 (id,name,bj,memo )
select id,name,0,'备注' from 产品表 where
产品表.id not in (select id from 报价产品表)