首页 \ 问答 \ 如何使用具有多个结果的子查询将值插入到表中?(How can I insert values into a table, using a subquery with more than one result?)

如何使用具有多个结果的子查询将值插入到表中?(How can I insert values into a table, using a subquery with more than one result?)

我真的很感激你的帮助。

可能这是一个非常简单的问题要解决 - 但我不是一个..--)

我在SQL Server中有两个表:

  1. 文章
  2. 价格

现在我想选择一组ids,并将这些ID插入到price-table中。

例如(错误而不工作的SQL)

INSERT INTO prices (group, id, price) 
VALUES (7, (select articleId from article WHERE name LIKE 'ABC%'), 1.50);

SQL错误 - >子查询具有超过1个值

感谢帮助


I really would appreciate your help.

Probably it's a quite simple problem to solve - but I'm not the one .. ;-)

I have two tables in SQL Server:

  1. article
  2. prices

Now I want to select a certain set of ids and insert some entries into the prices-table with those ID.

e.g. (wrong and not working SQL)

INSERT INTO prices (group, id, price) 
VALUES (7, (select articleId from article WHERE name LIKE 'ABC%'), 1.50);

SQL Error -> subquery has more than 1 value

thanks for help


原文:https://stackoverflow.com/questions/9692319
更新时间:2023-08-06 18:08

最满意答案

$('li')将为您提供所有li元素对象。

请检查以下示例: -

$(document).ready(function(){
  var data = [];
  $('li').each(function(){
    data.push($(this).text());
  });

  console.log(data);
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<ul>
    <li>new</li>
    <li>howler monkey</li>
    <li>pine marten</li>
</ul>


$('li') will give you all of li element objects.

Please Check below example:-

$(document).ready(function(){
  var data = [];
  $('li').each(function(){
    data.push($(this).text());
  });

  console.log(data);
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<ul>
    <li>new</li>
    <li>howler monkey</li>
    <li>pine marten</li>
</ul>

相关问答

更多
  • $('li')将为您提供所有li元素对象。 请检查以下示例: - $(document).ready(function(){ var data = []; $('li').each(function(){ data.push($(this).text()); }); console.log(data); });