让我们缩短一下。我有三个名为Invoice_Info,Invoice_print,Product_sold的表。表定义如下:
Invoice_Info:
[InvoiceNo]
[InvoiceDate]
[SubTotal]
[VATPer]
[DiscountPer]
[GrandTotal]
[TotalPayment]
Invoice_print:
[InvoiceNo]
[InvoiceDate]
[SubTotal]
[VATPer]
[DiscountPer]
[GrandTotal]
[TotalPayment]
ProductSold:
[Id]
[InvoiceNo]
[ProductID]
[ProductName]
[Price]
现在我需要根据productSold的invoiceNo匹配将invoice_info中存在的数据复制到invoice_print。 在每次复制之前我需要删除Invoice_print中存在的所有值。 所以我写了要从invoice_print中删除的查询:
Delete from Invoice_print
然后将值从invoice_info复制到invoice_print我写道:
INSERT INTO Invoice_print (InvoiceNo, InvoiceDate, SubTotal, VATPer, DiscountPer, GrandTotal, TotalPayment)
SELECT InvoiceNo,
InvoiceDate,
Subtotal,
VATPer,
DiscountPer,
GrandTotal,
TotalPayment
FROM Invoice_Info.ProductSold
WHERE Invoice_info.InvoiceNo = ProductSold.InvoiceNo
AND Invoice_Info.invoiceNo = txtInvoiceno.TEXT
这里我从名为txtInvoiceno的文本框中获取了一个值。 这个查询给了我错误
不明确的列名“InvoiceNo”
如何解决这个问题? 任何形式的帮助表示赞赏。在此先感谢
答案 0 :(得分:0)
只需替换
SELECT InvoiceNo
与
SELECT ProductSold.InvoiceNo
它将开始工作