SQL 中 INSERT INTO 查询中的多个 SELECT 语句
INSERT INTO TextTable(Number, Tokens)
SELECT
(SELECT ID FROM Tureme WHERE leksem IN
(SELECT Tokens FROM Text)),
(SELECT Tokens FROM Text WHERE Tokens IN
(SELECT leksem FROM Tureme));
TextTable 有两列->数量、代币 Tureme 有两列 -> ID(主键),leksem 和 文本有一栏 ->令牌
我的表:
TextTable 为空。
我想做的是将这些子查询的结果插入到 TextTable 中。子查询单独工作完美。但是,当我一起运行它时,它不会插入子查询的结果,并且会给出错误消息:
子查询返回超过 1 个值。当子查询跟在 =、!=、<、<=、>、>= 后面或子查询用作表达式时,这是不允许的。 该声明已终止。
我应该怎么办?
第一个子查询返回: 第二子查询返回:
ID &nb &nb 标记
4 apple
6 melon
9 pear
我想用这些值填充 TextTable。
INSERT INTO TextTable(Number, Tokens)
SELECT
(SELECT ID FROM Tureme WHERE leksem IN
(SELECT Tokens FROM Text)),
(SELECT Tokens FROM Text WHERE Tokens IN
(SELECT leksem FROM Tureme));
TextTable has two columns-> Number,Tokens
Tureme has two columns -> ID(Primary Key), leksem
and
Text has one column -> Tokens
My tables:
TextTable is empty.
What I'm trying to do is inserting the results of these subqueries into TextTable. The subqueries works perfect individually. But, when I run it together, it doesn't insert results of subqueries and it gives an error saying:
Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.
The statement has been terminated.
What should i do?
First subquery returns: Second subquery returns:
ID Tokens
4 apple
6 melon
9 pear
I want to populate TextTable with these values.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
根据您的新评论,这就是您想要的 select 语句。
您需要在查询中连接表 - 否则结果不会相互关联。
Based on your new comments this is what you want for the select statement
You need to join the tables in the query -- otherwise the results don't relate to each other.
我想这正是你想要的。
I guess this is exactly what you want.