Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Wny "JOIN expression not supported"? Expand / Collapse
Author
Message
Posted Tuesday, June 4, 2013 9:00 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Thursday, February 20, 2014 9:52 AM
Points: 19, Visits: 49
Hi everybody,

I thought I had a well laid out query but I keep getting the "JOIN expression not supported" error. Any help you could provide would be greatly appreciated.

Thank you.
momba

select 
supertable.Date
, supertable.[Lname, Fname]
, xxxSTAFF.Last
, xxxSTAFF.First
, xxxSTAFF.File
, xxxSTAFF.Title
, xxxSTAFF.PayrollTitle
, xxxSTAFF.Bank
, xxxSTAFF.[Active Staff] AS Active
, supertable.Reason
, supertable.DOECode
, xxxAbsenceReasons.ReasonDesc
, xxxAbsenceReasons.DOECode
, supertable.Substitute
, supertable.Comment
, supertable.OP198
, supertable.OP201
, supertable.EIS
, xxxBanks.Desc AS BankTitle
, xxxPayrollBankGroups.Group
, [xxxOES Sites].Principal
, [xxxOES Sites].AsstPrin
, [xxxOES Sites].Site
, xxxSTAFF.[Official Class] AS SiteID

FROM
(((((
(
select distintct * from
(
SELECT [Lname, Fname], Date , Reason , DOECode, Substitute, Comment, OP198, OP201, EIS
FROM [OES Absence]
union
SELECT [Lname, Fname], Date , Reason , DOECode, Substitute, Comment, OP198, OP201, EIS
FROM [xxxOES Absence 2011 - 2012 thru 20120807]
union
SELECT [Lname, Fname], Date , Reason , DOECode, Substitute, Comment, OP198, OP201, EIS
FROM [xxxOES Absence 2010 - 2011 thru 20120113]
union
SELECT [Lname, Fname], Date , Reason , DOECode, Substitute, Comment, OP198, OP201, EIS
FROM [xxxOES Absence 2009 - 2010 thru 20101209]
union
SELECT [Lname, Fname], Date , Reason , DOECode, Substitute, Comment, OP198, OP201, EIS
FROM [xxxOES Absence 2008 - 2009 thru 20100525]
union
SELECT [Lname, Fname], Date , Reason , DOECode, Substitute, Comment, OP198, OP201, EIS
FROM [xxxOES Absence 2007 - 2008]
union
SELECT [Lname, Fname], Date , Reason , DOECode, Substitute, Comment, OP198, OP201, EIS
FROM [xxxOES Absence 2006 - 2007]
)
) supertable

LEFT JOIN xxxSTAFF on (supertable.[Lname, Fname] = (xxxSTAFF.[Last] &", " &xxxSTAFF.[first] &" " &xxxSTAFF.[file]))
)
LEFT JOIN xxxAbsenceReasons on (supertable.Reason = xxxAbsenceReasons.Reason AND xxxSTAFF.Bank = xxxAbsenceReasons.Bank)
)
LEFT JOIN xxxBanks on xxxSTAFF.Bank = xxxBanks.Bank
)
LEFT JOIN xxxBanks on xxxSTAFF.Bank = xxxBank.Bank
)
LEFT JOIN xxxPayrollBankGroups ON xxxBanks.Bank = xxxPayrollBankGroups.Bank
)
LEFT JOIN [xxxOES Sites] ON xxxSTAFF.[Official Class] = [xxxOES Sites].[Official Class]

WHERE [xxxOES Sites].[CLOSED SITE]=No

Post #1459812
Posted Tuesday, June 4, 2013 9:37 AM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Yesterday @ 7:22 AM
Points: 170, Visits: 628
You are joining on an expression on the right side, while the left side appears to be the two name fields separately. Create the same expression on the left side, and it should work.

Wendell
Colorful Colorado
You can't see the view if you don't climb the mountain!
Post #1459838
Posted Tuesday, June 4, 2013 10:31 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Thursday, February 20, 2014 9:52 AM
Points: 19, Visits: 49
As suggested, I revised the code (see below) but now I'm getting the error "Syntax error in JOIN expression". I can't seem to spot the issue...

select 
supertable.Date
, supertable.[Lname, Fname]
, xxxSTAFF.Last
, xxxSTAFF.First
, xxxSTAFF.File
, xxxSTAFF.Title
, xxxSTAFF.PayrollTitle
, xxxSTAFF.Bank
, xxxSTAFF.[Active Staff] AS Active
, supertable.Reason
, supertable.DOECode
, xxxAbsenceReasons.ReasonDesc
, xxxAbsenceReasons.DOECode
, supertable.Substitute
, supertable.Comment
, supertable.OP198
, supertable.OP201
, supertable.EIS
, xxxBanks.Desc AS BankTitle
, xxxPayrollBankGroups.Group
, [xxxOES Sites].Principal
, [xxxOES Sites].AsstPrin
, [xxxOES Sites].Site
, xxxSTAFF.[Official Class] AS SiteID

FROM
(((
(
Select Bank & Reason AS BankReason, * from
(
select distinct * from
(
SELECT [Lname, Fname], Date , Reason , DOECode, Substitute, Comment, OP198, OP201, EIS
FROM [OES Absence]
union
SELECT [Lname, Fname], Date , Reason , DOECode, Substitute, Comment, OP198, OP201, EIS
FROM [xxxOES Absence 2011 - 2012 thru 20120807]
union
SELECT [Lname, Fname], Date , Reason , DOECode, Substitute, Comment, OP198, OP201, EIS
FROM [xxxOES Absence 2010 - 2011 thru 20120113]
union
SELECT [Lname, Fname], Date , Reason , DOECode, Substitute, Comment, OP198, OP201, EIS
FROM [xxxOES Absence 2009 - 2010 thru 20101209]
union
SELECT [Lname, Fname], Date , Reason , DOECode, Substitute, Comment, OP198, OP201, EIS
FROM [xxxOES Absence 2008 - 2009 thru 20100525]
union
SELECT [Lname, Fname], Date , Reason , DOECode, Substitute, Comment, OP198, OP201, EIS
FROM [xxxOES Absence 2007 - 2008]
union
SELECT [Lname, Fname], Date , Reason , DOECode, Substitute, Comment, OP198, OP201, EIS
FROM [xxxOES Absence 2006 - 2007]
)
) allabsences
LEFT JOIN xxxSTAFF on (allabsences.[Lname, Fname] = (xxxSTAFF.[Last] &", " &xxxSTAFF.[first] &" " &xxxSTAFF.[file]))
) supertable
LEFT JOIN xxxAbsenceReasons on (supertable.BankReason = (xxxAbsenceReasons.Bank & xxxAbsenceReasons.Reason))
)
LEFT JOIN xxxBanks on xxxSTAFF.Bank = xxxBanks.Bank
)
LEFT JOIN xxxPayrollBankGroups ON xxxBanks.Bank = xxxPayrollBankGroups.Bank
)
LEFT JOIN [xxxOES Sites] ON xxxSTAFF.[Official Class] = [xxxOES Sites].[Official Class]

WHERE [xxxOES Sites].[CLOSED SITE]=No

Post #1459856
Posted Tuesday, June 4, 2013 10:36 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Today @ 9:31 AM
Points: 12,962, Visits: 32,501
i had to add one more alias near the end to get this to parse correctly in SQL:
(also several columns are using reserved word names: xxxSTAFF.[File],xxxBanks.[Desc], xxxPayrollBankGroups.[Group])



...
FROM [xxxOES Absence 2006 - 2007]
) AnotherAlias
) allabsences
LEFT JOIN xxxSTAFF
...



Lowell

--There is no spoon, and there's no default ORDER BY in sql server either.
Actually, Common Sense is so rare, it should be considered a Superpower. --my son
Post #1459857
Posted Tuesday, June 4, 2013 10:56 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Thursday, February 20, 2014 9:52 AM
Points: 19, Visits: 49
same syntax error...
select 
supertable.Date
, supertable.[Lname, Fname]
, xxxSTAFF.Last
, xxxSTAFF.First
, xxxSTAFF.File AS FileNum
, xxxSTAFF.Title
, xxxSTAFF.PayrollTitle
, xxxSTAFF.Bank
, xxxSTAFF.[Active Staff] AS Active
, supertable.Reason
, xxxAbsenceReasons.ReasonDesc
, xxxAbsenceReasons.DOECode
, supertable.Substitute
, supertable.Comment
, supertable.OP198
, supertable.OP201
, supertable.EIS
, xxxBanks.Desc AS BankTitle
, xxxPayrollBankGroups.Group AS GroupNum
, [xxxOES Sites].Principal
, [xxxOES Sites].AsstPrin
, [xxxOES Sites].Site
, xxxSTAFF.[Official Class] AS SiteID
FROM
(((
(
Select Bank & Reason AS BankReason, * from
(
select distinct * from
(
SELECT [Lname, Fname], Date , Reason , DOECode, Substitute, Comment, OP198, OP201, EIS
FROM [OES Absence]
union
SELECT [Lname, Fname], Date , Reason , DOECode, Substitute, Comment, OP198, OP201, EIS
FROM [xxxOES Absence 2011 - 2012 thru 20120807]
union
SELECT [Lname, Fname], Date , Reason , DOECode, Substitute, Comment, OP198, OP201, EIS
FROM [xxxOES Absence 2010 - 2011 thru 20120113]
union
SELECT [Lname, Fname], Date , Reason , DOECode, Substitute, Comment, OP198, OP201, EIS
FROM [xxxOES Absence 2009 - 2010 thru 20101209]
union
SELECT [Lname, Fname], Date , Reason , DOECode, Substitute, Comment, OP198, OP201, EIS
FROM [xxxOES Absence 2008 - 2009 thru 20100525]
union
SELECT [Lname, Fname], Date , Reason , DOECode, Substitute, Comment, OP198, OP201, EIS
FROM [xxxOES Absence 2007 - 2008]
union
SELECT [Lname, Fname], Date , Reason , DOECode, Substitute, Comment, OP198, OP201, EIS
FROM [xxxOES Absence 2006 - 2007]
) allabsences
) dstabsences
LEFT JOIN xxxSTAFF on (dstabsences.[Lname, Fname] = (xxxSTAFF.[Last] &", "& xxxSTAFF.[first] &" "& xxxSTAFF.[file]))
) supertable
LEFT JOIN xxxAbsenceReasons on (supertable.BankReason = (xxxAbsenceReasons.Bank & xxxAbsenceReasons.Reason))
)
LEFT JOIN xxxBanks on xxxSTAFF.Bank = xxxBanks.Bank
)
LEFT JOIN xxxPayrollBankGroups ON xxxBanks.Bank = xxxPayrollBankGroups.Bank
)
LEFT JOIN [xxxOES Sites] ON xxxSTAFF.[Official Class] = [xxxOES Sites].[Official Class]

WHERE [xxxOES Sites].[CLOSED SITE]=No

Post #1459866
Posted Tuesday, June 4, 2013 2:00 PM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Thursday, February 20, 2014 9:52 AM
Points: 19, Visits: 49
I figured it out, I figured it out, I FIGURED IT OUT!!!!!
select 
supertable.Date
, supertable.[Lname, Fname]
, supertable.Last
, supertable.First
, supertable.File AS FileNum
, supertable.Title
, supertable.PayrollTitle
, supertable.Bank
, supertable.[Active Staff] AS Active
, supertable.Reason
, xxxAbsenceReasons.ReasonDesc
, xxxAbsenceReasons.DOECode
, supertable.Substitute
, supertable.Comment
, supertable.OP198
, supertable.OP201
, supertable.EIS
, xxxBanks.Desc AS BankTitle
, xxxPayrollBankGroups.Group AS GroupNum
, [xxxOES Sites].Principal
, [xxxOES Sites].AsstPrin
, [xxxOES Sites].Site
, supertable.[Official Class] AS SiteID
FROM
(((
(
Select Bank & Reason AS BankReason, * from
(
select distinct * from
(
SELECT [Lname, Fname], Date , Reason , DOECode, Substitute, Comment, OP198, OP201, EIS
FROM [OES Absence]
union
SELECT [Lname, Fname], Date , Reason , DOECode, Substitute, Comment, OP198, OP201, EIS
FROM [xxxOES Absence 2011 - 2012 thru 20120807]
union
SELECT [Lname, Fname], Date , Reason , DOECode, Substitute, Comment, OP198, OP201, EIS
FROM [xxxOES Absence 2010 - 2011 thru 20120113]
union
SELECT [Lname, Fname], Date , Reason , DOECode, Substitute, Comment, OP198, OP201, EIS
FROM [xxxOES Absence 2009 - 2010 thru 20101209]
union
SELECT [Lname, Fname], Date , Reason , DOECode, Substitute, Comment, OP198, OP201, EIS
FROM [xxxOES Absence 2008 - 2009 thru 20100525]
union
SELECT [Lname, Fname], Date , Reason , DOECode, Substitute, Comment, OP198, OP201, EIS
FROM [xxxOES Absence 2007 - 2008]
union
SELECT [Lname, Fname], Date , Reason , DOECode, Substitute, Comment, OP198, OP201, EIS
FROM [xxxOES Absence 2006 - 2007]
) allabsences
) dstabsences
LEFT JOIN xxxSTAFF on (dstabsences.[Lname, Fname] = (xxxSTAFF.[Last] &", "& xxxSTAFF.[first] &" "& xxxSTAFF.[file]))
) supertable
LEFT JOIN xxxAbsenceReasons on (supertable.BankReason = (xxxAbsenceReasons.Bank & xxxAbsenceReasons.Reason))
)
LEFT JOIN xxxBanks on supertable.Bank = xxxBanks.Bank
)
LEFT JOIN xxxPayrollBankGroups ON xxxBanks.Bank = xxxPayrollBankGroups.Bank
)
LEFT JOIN [xxxOES Sites] ON supertable.[Official Class] = [xxxOES Sites].[Official Class]

WHERE [xxxOES Sites].[CLOSED SITE]=No

Thanks for your help!
Post #1459931
Posted Tuesday, June 4, 2013 3:52 PM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Yesterday @ 7:22 AM
Points: 170, Visits: 628
FWIW, if you are a relative novice at creating SQL statements in Access, the query designer will do a very nice job for you and make troubleshooting such statements much easier. (I even use the SQL Server query designer on occasion.)

Wendell
Colorful Colorado
You can't see the view if you don't climb the mountain!
Post #1459973
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse