简体   繁体   English

查询的ms-access语法

[英]ms-access syntax of a query

I have a query that looks like: 我有一个查询,看起来像:

select distinctrow company.* from company, contact, address, company 
  left join address on company.com_uid = address.com_uid, company 
  left join contact on company.com_uid = contact.com_uid

It is the base-query inside of an application which sets, upon user-input, dynamicaly the where-clause, eg: 它是应用程序内部的基础查询,可根据用户输入动态设置位置子句,例如:

where contact.function like 'C*'

or 要么

where address.state = 'de'

this query shows all relevant companies. 该查询显示所有相关公司。 The App changes little to show the searched contacs: 该应用程序几乎没有变化,无法显示搜索到的内容:

select distinctrow contacts.* from company, contact, address, company 
  left join address on company.com_uid = address.com_uid, company 
  left join contact on company.com_uid = contact.com_uid

or the searched addresses: 或搜索到的地址:

select distinctrow address.* from company, contact, address, company 
  left join address on company.com_uid = address.com_uid, company 
  left join contact on company.com_uid = contact.com_uid

DISTINCTROW is mandatory because there are images and columns of datatype memo in all the tables. DISTINCTROW是强制性的,因为所有表中都有图像和数据类型备忘的列。 Beside the questions concerning performance, who know this sort of syntax and where does it come from? 除了有关性能的问题外,谁知道这种语法,它又是从哪里来的呢?

If I understand your question, you're asking why Access has a different style of SQL Syntax than SQL Server. 如果我理解您的问题,您是在问为什么Access具有与SQL Server不同的SQL语法样式。

Access, and several other Microsoft products, use the Microsoft Jet Database Engine . Access和其他几种Microsoft产品都使用Microsoft Jet数据库引擎

As you've noticed, there can be some frustrating differences between this flavor of SQL and what you're typically used to seeing in T-SQL. 您已经注意到,这种SQL风格与您通常在T-SQL中经常看到的风格之间可能会有令人沮丧的差异

In addition to the list of differences, this reference for Microsoft Jet in Access 2003 might be helpful for you. 除了差异列表之外,Access 2003中有关Microsoft Jet的参考也可能对您有所帮助。

The Access Database Engine (Jet, ACE, whatever) does not implement the SQL-92 syntax; Access数据库引擎(Jet,ACE等)不实现SQL-92语法; see Outer Join with WHERE Clause Returns Unexpected Records . 请参阅带有WHERE子句的外部联接返回意外记录

For even more detail, see this Joe Celko newsgroup thread : 有关更多详细信息,请参见Joe Celko新闻组线程

Yes, ACCESS is dead wrong as usual. 是的,访问仍然像往常一样完全错误。 And they know about it. 他们知道这一点。 I got called in on this one as a consultant, to provide quotes from the SQL- 92 Standard. 我以顾问的身份受邀参加此会议,以提供SQL-92标准的报价。 The Jet Engine gorup wanted to fix the parser, but some of the product groups in Microsoft have code that depends on these bugs. Jet Engine专家组希望修复该解析器,但是Microsoft中的某些产品组具有依赖于这些错误的代码。 You see who won. 你看谁赢了。

I can provide similar articles about the disaster that is DISTINCTROW if you like ;) 如果您愿意,我可以提供有关DISTINCTROW灾难的类似文章;

DISTINCT versus DISTINCTROW DISTINCT与DISTINCTROW

This article is designed for the person who is learning Access, as opposed to someone already conversant with SQL. 本文专为正在学习Access的人员而不是已经精通SQL的人员而设计。 But it's a fine explanation from either vantage. 但这两种说法都是很好的解释。

http://www.fmsinc.com/microsoftaccess/query/distinct_vs_distinctrow/unique_values_records.asp http://www.fmsinc.com/microsoftaccess/query/distinct_vs_distinctrow/unique_values_records.asp

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM