如何根据结果查询插入和更新
我需要根据某些结果进行查询以插入和更新。类似的事情:
INSERT INTO table1(name)
SELECT 'myname' FROM table2 t2 WHERE t2.lastname = 'lastname';
该查询应该返回多行,因此我需要根据该结果从Table2更新年龄字段,这就是我不知道该如何处理。有什么想法吗?
I need to make a query to insert and update based on select results. Something like this:
INSERT INTO table1(name)
SELECT 'myname' FROM table2 t2 WHERE t2.lastname = 'lastname';
That query is supposed to return multiple rows so then I need to update age field from table2 based on that results and that's I don't know how to aprroach it. Any idea?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可能需要使用Oracle Merge Statment。由于您尚未阐述您的问题,因此不可能给出确切的答案。
You may want to use the oracle merge statment. Since you have not elaborated your question, giving the exact answer is not possible.