使用“插入”和“选择查询”插入数据 [英] Inserting Data using Insert and Select Query

查看:91
本文介绍了使用“插入”和“选择查询”插入数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好..



我的sql有问题。



Hello all..

I am having a problem with sql.

INSERT INTO Customers (ContactName, CustomerName, Country) Values  ('Islamabad',
SELECT SupplierName, Country FROM Suppliers);





我想手动插入联系人名称,并且想要从Customers表中的Suppliers表中插入SupplierName和Country。



我收到语法错误近选择。



I want to insert contactname manually and and want to insert SupplierName and Country from the Suppliers table in Customer table.

I am getting Syntax Error Near Select.

推荐答案

我们通常像bellow查询一样插入。相应地

We usually do insert like the bellow query. Do accordingly
INSERT INTO Customers (ContactName, CustomerName, Country) 
SELECT 'Islamabad',SupplierName, Country FROM Suppliers


尝试这样的事情.. 。

Try something like this ...
INSERT INTO Customers (ContactName, CustomerName, Country)
SELECT 'Islamabad', SupplierName, Country FROM Suppliers


这篇关于使用“插入”和“选择查询”插入数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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