views:

239

answers:

4

Can someone please help me out with a query? In Microsoft SQL Server, I have the following query, which executes fine:

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. 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. Any help would be useful!

A: 

Use this sintax in access never fails

(this is an example)

select * from customer, adress where customer.id = adress.customerId

daniel
A: 

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

shahkalpesh
+5  A: 

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.

Remou
Within Access, you can use % and _ as wildcards if you have ANSI 92 SQL mode turned on.
David-W-Fenton
Thanks for the response Remou. It was the parenthesis I forgot. SQL Server does not require them, but Access does. Thanks for the help
icemanind
A: 

The syntax error is caused because access uses " instead of ' as the string delimiter. As previously mentioned you will also need to change the % wildcards to *

pipTheGeek
I am afraid that this is not true.
Remou