在VB网络中使用SELECT DISTINCTROW [英] Use SELECT DISTINCTROW in VB net

查看:231
本文介绍了在VB网络中使用SELECT DISTINCTROW的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hello Everybody !!



有谁知道sql命令SELECT DISTINCTROW是否可以在VB 2017代码中使用?



我正在尝试开发一个查询,我需要从两个表中选择单个唯一记录,但它不起作用。如果我将其更改为SELECT DISTINCT,它可以正常工作,但这不是我需要的。如果我保留SELECT DISTINCTROW语句,VS 2017会一直告诉我语法错误。



查询最初是在Access(环境,而不是数据库) 2010 VBA代码,它在那里运行得很好,现在我需要将它导出到VB Net。它是一个子查询,将信息传递给更高级别的另一个(第二个)查询。



我真的很感激任何帮助或提示。



我尝试过:



通过互联网搜索并尝试至少为第一个查询开发SQL存储过程,然后尝试使用参数从中选择数据。



但是SQL管理器不接受SELECT DISTINCTROW statemente;它说的是一个无效的列。

Hello Everybody !!

Does anybody knows if the sql command "SELECT DISTINCTROW" can be used in VB 2017 code ?.

I'm trying to develop a query in which I need to select single unique records from two tables and it just doesn't work. If I change it to "SELECT DISTINCT" it works fine, but that's not what I need. If I keep the "SELECT DISTINCTROW' statement, VS 2017 keeps telling me there's a syntax error.

The query originally is in Access (the environment, not the database) 2010 VBA code and it runs perfectly there, and now I need to export it to VB Net. It is a sub-query that passes information to another (second) query of a higher level.

I'd really appreciate any help or tip.

What I have tried:

Searching thru the Internet and trying to develop a SQL Stored Procedure at least for the first query, and then trying to select data from it with a parameter.

But the SQL manager doesn't accept the SELECT DISTINCTROW statemente; it says is an invalid column.

推荐答案

DISTINCTROW 谓词是特定于MS Access数据库引擎。正如MSDN文档所述, DISTINCT 和<之间存在细微差别code> DISTINCTROW :

  • DISTINCT - 忽略包含重复数据的记录< u>在选定的字段中。
  • DISTINCTROW - 在整个重复记录上忽略基于的数据,而不仅仅是重复的字段。例如,您可以创建一个连接CustomerID字段上的Customers和Orders表的查询。 Customers表不包含重复的CustomerID字段,但Orders表的确存在,因为每个客户可以有很多订单。以下SQL语句显示了如何使用DISTINCTROW生成至少有一个订单但没有关于这些订单的任何详细信息的公司列表。
DISTINCTROW predicate is MS Access database engine specific. As MSDN documentation states, there's small difference between DISTINCT and DISTINCTROW:
  • DISTINCT - Omits records that contain duplicate data in the selected fields.
  • DISTINCTROW - Omits data based on entire duplicate records, not just duplicate fields. For example, you could create a query that joins the Customers and Orders tables on the CustomerID field. The Customers table contains no duplicate CustomerID fields, but the Orders table does because each customer can have many orders. The following SQL statement shows how you can use DISTINCTROW to produce a list of companies that have at least one order but without any details about those orders.


这篇关于在VB网络中使用SELECT DISTINCTROW的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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