|
Subject:
|
Access Query
|
|
Posted By:
|
gre_smi
|
Post Date:
|
1/11/2006 3:02:49 AM
|
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.
Error:-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.'.
Query:-
SELECT Instrument.InstrumentCode, Instrument.InstrumentDescription, IIf( IsNull,'Unassigned',"GrpName") AS GrpName, IIf( IsNull,'Unassigned',"CategoryName") AS CatName,InsCategory.CategoryDescription, InsSubCategory.SubCategoryDescription,InsClass.ClassDescription 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
|
|
Reply By:
|
mmcdonal
|
Reply Date:
|
1/11/2006 7:40:42 AM
|
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.
HTH
mmcdonal
|
|
Reply By:
|
Jeff Mason
|
Reply Date:
|
1/11/2006 7:59:07 AM
|
Looks like you're missing at least one ")".
Shouldn't
... LEFT JOIN InsCategory ON (Instrument.ReportDate = InsCategory.ReportDate
AND Instrument.RevisionDate = InsCategory.RevisionDate
AND Instrument.CategoryCode = InsCategory.CategoryCode
LEFT JOIN InsClass ...
be
...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. www.custom-apps.com
|
|