如何从两个不同的表中选择列

编程入门 行业动态 更新时间:2024-10-28 04:23:06
本文介绍了如何从两个不同的表中选择列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有一个带有DataGrinView的表单,我需要DataGrinView来显示来自2个不同表格的特定列。 我试过这个查询:

I have a form with a DataGrinView and I need that DataGrinView to show me specific columns from 2 distinct tables. I have tried this query:

<SELECT TransDocument, TransSerial, TransDocNumber, PartyName, PartyLocalityID, TotalAmount, ShipToPostalCode FROM dbo.UXFaturas , dbo.SaleTransaction where Estado = 0

但我得到了这个错误:

but I got this error:

Error trying to create the parameterized query Invalid column name 'TransDocument1'. Invalid column name 'TransSerial'. Invalid column name 'TransDocNumber'.

我正在使用的列的名称不是我的那些调用查询为什么我会收到此错误?如果您需要有关我的SQL数据库的更多信息,请随时询问。 我尝试过:

The names of the columns that I'm using arent the ones I'm calling on the query why do I get this error? If you need more information about my sql database feel free to ask. What I have tried:

SELECT TransDocument, TransSerial, TransDocNumber, PartyName, PartyLocalityID, TotalAmount, ShipToPostalCode FROM dbo.UXFaturas , dbo.SaleTransaction where Estado = 0

推荐答案

您好, SQL解析器需要了解哪些列属于哪些表。在你的情况下,你没有具体说明。 所以,首先,你需要为每一列指定,你可以使用别名用于此目的。然后,您需要指定应读取每个表中的哪些数据。为此,您可以使用加入。但是要使用连接,你需要一个在两个表中都很常见的列。 如果没有,你可能想看一下回答这个 CP问题。 谢谢,祝你好运。 Hi, The SQL parser needs to understand which columns belong to which tables. In your case, you do not specifically say that. So, first of all, you need to specify that for each column, and you can use aliases for that purpose. Then you need to specify which data from each table should be read. For that, you can use joins. But to use joins, you will need a column that is common in both the tables. If there aren't any, you might want to take a look at the answer to this CP question. Thanks and good luck.

更多推荐

如何从两个不同的表中选择列

本文发布于:2023-10-27 18:21:54,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1534165.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:两个

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!