将 Insert 语句放入 Select 语句中 [英] Place an Insert Statement into a Select Statement

查看:96
本文介绍了将 Insert 语句放入 Select 语句中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已阅读其他问题以及所有已发布的评论/对与此问题类似的问题的回答.他们似乎都没有直接回答这个问题.

我想知道是否有办法将 INSERTDELETEUPDATE 语句连接或放入 语句中>SELECT 语句.

I am wanting to know if there is a way to either concatenate or place an INSERT, DELETE or UPDATE statement into a SELECT statement.

如果是这样怎么办?这是否可以通过使用派生表 函数或subSelect 语句来完成?

If so how? Could this be done by using a derived table function or a subSelect statement?

例如:

INSERT INTO Customer (name)
VALUES 'Test Name'

但将其放入 SELECT 语句

示例伪代码:

SELECT *
FROM Customer
WHERE
Customer.name = (INSERT INTO Customer (name) VALUES 'Test Name')

这里最重要的事情是以非常规的方式将 INSERT 语句放入 SELECT 语句中.

The big thing here is getting the INSERT statement into the SELECT statement in an unconventional way.

谢谢,希望这会带来一些好的对话/想法/结果!

Thank you and hopefully this will strike up some good conversation/ideas/results!

想知道这个的原因:

  1. 我们当前的 DBMS(Fishbowl)不允许我们在 SQL 编译器中使用 UPDATE、DELETE 或 INSERT 语句,我们想要批量更改我们的字段/清理我们的表.
  2. 想知道是否有可能

推荐答案

您可能在 insert 中有一个 select,但反之则不然

You may have a select within an insert but not the other way around.

插入语句中的 select 语句可用于将值从一个表复制到另一个表.(你只是在从另一个表中读取数据后写入数据)

A select within an insert statement could be used to copy values from a table to another. (You are just writing into a table after a read from another)

但是在选择中插入是没有意义的!当您从表中运行选择(或只是读取数据)时,您要插入什么?(当您只允许读取时,怎么可能写入?)

But an insert within a select doesn't make sense! What are you going to insert when you are running a select from a table(or just reading data)?(how is it possible to write when you are only allowed to read?)

你的情况,如果你无权运行插入,那么你把语句放在哪里并不重要,你不能,因为你不被允许!

但是如果您谈论的是您的查询引擎/数据库包装器不允许直接插入,那么这可能是因为它需要一个应用程序/程序将数据插入到而不只是一个查询中(因为您的引擎还没有执行该操作的能力).

But if you are talking about your query engine/database wrapper not allowing a direct insert, then its probably because it requires an application/program to insert data into to rather than just a query(as your engine doesn't already have the capability to perform that operation).

这篇关于将 Insert 语句放入 Select 语句中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆