关于sql查询
我有下面的 sql 查询来从表中插入记录。问题是,当没有选择查询的记录时,我仍然想要插入序列号、null、'3' 值的记录。当没有找到选择查询的记录时,不会插入任何内容。我该怎么做?
insert into test_details(seqnbr,trepid,type)
select '&seqid'
,REP_ID
,'3'
FROM ref_details
WHERE REP_ID >13;
I have the below sql query to insert the records from a table. The problem is when there is no records for select query i still want an record with the sequence number,null,'3' value inserted. Nothing get's inserted when there is no record found for select query. how can i do it?
insert into test_details(seqnbr,trepid,type)
select '&seqid'
,REP_ID
,'3'
FROM ref_details
WHERE REP_ID >13;
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
一种方法是
One way would be
Oracle 9i+:
要填补空白,您需要 创建一个序列值列表:
...然后 LEFT JOIN 到可以有间隙的表。
Oracle 9i+:
To fill in gaps, you need to create a list of sequencial values:
...then LEFT JOIN to the table that can have gaps.