从一个表中获取数据并将其传输到另一个表 [英] Getting data from one table and transferring it to another

查看:87
本文介绍了从一个表中获取数据并将其传输到另一个表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我正在使用HeidiSQL进行当前操作,而我的问题是我无法弄清楚如何从一个表中获取数据,并将其插入到具有相同列名的另一张表中...
到目前为止,我的查询是:

Hi,
I am currecntly working with HeidiSQL, and my problem is that I cannot figure out how to get data from one table, and insert it into a different table that has the same column names...
My query so far is:

INSERT INTO tbltransactions (TransactionID, TransactionDate, PaymentMethod, CashTendered, CustomerID)
SELECT (trans_id, date_time, payment_method, cash_tendered, customer_id) FROM shop_transactions


只是想知道是否有人能看到我在这里犯的错误,因为我看不到!出现的错误消息是:


Just wondering whether anyone can see the error I am making here as I can''t! The error message that appears is:

SQL Error (1241): Operand should contain 1 column(s)

谢谢大家,
Tom.

Thanks guys,
Tom.

推荐答案

尝试删除列周围的():
Try removing the () around the columns :
INSERT INTO tbltransactions (TransactionID, TransactionDate, PaymentMethod, CashTendered, CustomerID)
SELECT trans_id, date_time, payment_method, cash_tendered, customer_id FROM shop_transactions


尝试卸下括号.
Try removing brackets.
INSERT INTO tbltransactions (TransactionID, TransactionDate, PaymentMethod, CashTendered, CustomerID)
SELECT trans_id, date_time, payment_method, cash_tendered, customer_id FROM shop_transactions


将tableName1(column1(数据类型),column2(数据类型))值插入(从tableanme2中选择column1,column2)
Insert Into tableName1 (column1 (datatype),column2(datatype)) values(select column1, column2 from tableanme2)


这篇关于从一个表中获取数据并将其传输到另一个表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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