简体   繁体   English

Microsoft Access SQL查询

[英]Microsoft Access SQL query

Can someone please help me out with a query? 有人可以帮我一个查询吗? In Microsoft SQL Server, I have the following query, which executes fine: 在Microsoft SQL Server中,我有以下查询,可以很好地执行:

SELECT * FROM ControlPoint
INNER JOIN Project ON ControlPoint.ProjectID = Project.ProjectID
INNER JOIN Site ON Site.SiteID = Project.SiteID
WHERE Project.ProjectName LIKE '%Flood%'

My problem is, when I try to execute this on Microsoft Access, it gives me some kind of syntax error. 我的问题是,当我尝试在Microsoft Access上执行此操作时,它给了我某种语法错误。 It's been forever since I've used Access, but if I remember right, I think the joins need to be in parenthesis or something. 自从我使用Access以来,这已经很长了,但是如果我没记错的话,我认为联接必须在括号内。 Any help would be useful! 任何帮助将是有用的!

You will need some parentheses in addition to changing the wild cards: 除了更改通配符之外,您还需要一些括号:

SELECT * FROM (ControlPoint
INNER JOIN Project ON ControlPoint.ProjectID = Project.ProjectID)
INNER JOIN Site ON Site.SiteID = Project.SiteID
WHERE Project.ProjectName LIKE '*Flood*'

Note that the asterisk is used in the Access query window and with DAO, percent is used with ADO. 请注意,星号在Access查询窗口中使用,对于DAO,百分数用于ADO。

Access uses different wildcard patterns. 访问使用不同的通配符模式。
In your case, it will be - LIKE '?Flood?' 在您的情况下,将是-像“?洪水?” (replace question mark with asterisk). (用星号替换问号)。

I don't know formatting codes to apply here so that it shows it correctly. 我不知道要在此处应用格式代码,以便正确显示它。
See the link for details - http://www.techonthenet.com/access/queries/like.php 有关详细信息,请参见链接-http: //www.techonthenet.com/access/queries/like.php

由于访问使用“而不是”作为字符串定界符,因此引起语法错误。如前所述,您还需要将%通配符更改为*

Use this sintax in access never fails 在访问中使用此sintax永远不会失败

(this is an example) (这是一个例子)

select * from customer, adress where customer.id = adress.customerId 从客户地址中选择*,其中customer.id = adress.customerId

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

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