Wrox Programmer Forums
SQL Server 2000 General discussion of Microsoft SQL Server -- for topics that don't fit in one of the more specific SQL Server forums. version 2000 only. There's a new forum for SQL Server 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server 2000 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old January 11th, 2006, 04:02 AM
Registered User
Join Date: Nov 2005
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Access Query

Hi All
Could someone assist me with this.I have an Access Query that I try to run but it keeps giving me an error.

[u]Error:-</u>Syntax Error(Missing Operator)In Query Expression 'Instrument.InstrumentCode = GroupsRelationships.Instr_Port_Id LEFT JOIN GroupsCategories On GroupsRelationships.CategoryId = GroupsCategories.CategoryId LEFT JOIN Groups On GroupsCategories.GroupId = Groups.GroupId LEFT JOIN InsCategory On (Instrument.'.


SELECT Instrument.InstrumentCode, Instrument.InstrumentDescription, IIf( IsNull,'Unassigned',"GrpName") AS GrpName, IIf( IsNull,'Unassigned',"CategoryName") AS CatName,InsCategory.CategoryDescription, InsSubCategory.SubCategoryDescription,InsClass.Cla ssDescription FROM Instrument LEFT JOIN GroupsRelationships ON Instrument.InstrumentCode = GroupsRelationships.Instr_Port_ID
LEFT JOIN GroupsCategories ON GroupsRelationships.CategoryID = GroupsCategories.CategoryID
LEFT JOIN Groups ON GroupsCategories.GroupID = Groups.GroupID
LEFT JOIN InsCategory ON (Instrument.ReportDate = InsCategory.ReportDate
AND Instrument.RevisionDate = InsCategory.RevisionDate
AND Instrument.CategoryCode = InsCategory.CategoryCode
LEFT JOIN InsClass ON (Instrument.ClassCode = InsClass.ClassCode
AND Instrument.ReportDate = InsClass.ReportDate
AND Instrument.RevisionDate = InsClass.RevisionDate
LEFT JOIN InsSubCategory
ON Instrument.SubCategoryCode = InsSubCategory.SubCategoryCode
AND Instrument.ReportDate = InsSubCategory.ReportDate
AND Instrument.RevisionDate = InsSubCategory.RevisionDate
WHERE Instrument.RevisionDate = DateValue('" & RevisionDate & "')
AND Instrument.ReportDate = DateValue('" & ReportDate & "')
AND Groups.GroupName = ('" & Groups(0) & "')
AND Groups.GroupType = ('" & GroupType & "')
ORDER BY Instrument.InstrumentCode, GroupsRelationships.GroupID DESC ,
GroupsRelationships.CategoryID DESC ,
InsCategory.CategoryDescription, InsSubCategory.SubCategoryDescription, InsClass.ClassDescription
Old January 11th, 2006, 08:40 AM
Friend of Wrox
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts

Without getting into the syntax, Access uses ANSI 89, and SQL 2000 uses ANSI 92, so there may be some syntax screwing this up.

In any event, the better thing to do is to create your query on the SQL server and then just call the result set from the SQL view instead of pulling ALLLLLL the data, and then sorting it on the client.

SQL server will further optimize the view once created, and this will further speed the process.

If you need to further refine the results once on the client machine, just pull the initial query results into a temporary table on the client, and then run additional queries against it there.


Old January 11th, 2006, 08:59 AM
Friend of Wrox
Join Date: Jun 2003
Posts: 839
Thanks: 0
Thanked 1 Time in 1 Post

Looks like you're missing at least one ")".

... LEFT JOIN InsCategory ON (Instrument.ReportDate = InsCategory.ReportDate
AND Instrument.RevisionDate = InsCategory.RevisionDate
AND Instrument.CategoryCode = InsCategory.CategoryCode
LEFT JOIN InsClass ...
...LEFT JOIN InsCategory ON (Instrument.ReportDate = InsCategory.ReportDate
AND Instrument.RevisionDate = InsCategory.RevisionDate
AND Instrument.CategoryCode = InsCategory.CategoryCode)
LEFT JOIN InsClass ...
You should also consider being consistent in using parenthesis - some of your compound JOIN conditions have them, some don't, making it difficult for a human to parse them.

Jeff Mason
Custom Apps, Inc.

Similar Threads
Thread Thread Starter Forum Replies Last Post
Access query from a webpage? oldmainframehack Access VBA 1 August 13th, 2007 12:29 PM
MS Access Query rsm42 ASP.NET 1.0 and 1.1 Basics 2 March 20th, 2007 12:32 PM
Help with access query jrobertson Access VBA 6 January 25th, 2007 05:49 PM
need access query kale_tushar Access 2 January 3rd, 2005 05:26 AM
Access: need a Query. please help me... alienscript Access VBA 1 December 14th, 2003 01:02 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.