AnsweredAssumed Answered

Trouble adding ORDER BY to SQL statement

Question asked by deathrobot on Feb 11, 2015
Latest reply on Feb 12, 2015 by deathrobot

Title

Trouble adding ORDER BY to SQL statement

Post

Hi. I'm having trouble adding ORDER BY to an already working SQL statement. This statement works (the global variables are grabbed from two other looping scripts):

 

SELECT

People.id

 

FROM

People

 

LEFT JOIN

Companies ON People.id_Company = Companies.id

 

WHERE " & 

$$peopleWHERE 

 

&

 

" UNION

 

SELECT

id_People

 

FROM

DevPlayed

 

LEFT JOIN

DevInstruments ON DevPlayed.id_instruments = DevInstruments.id

 

WHERE " &

$$instrumentWHERE

 

;

 

 

 

Adding the ORDER BY causes it to fail:

 

 

 

SELECT

People.id

 

FROM

People

 

LEFT JOIN

Companies ON People.id_Company = Companies.id

 

WHERE " & 

$$peopleWHERE 

 

&

 

" UNION

 

SELECT

id_People

 

FROM

DevPlayed

 

LEFT JOIN

DevInstruments ON DevPlayed.id_instruments = DevInstruments.id

 

WHERE " &

$$instrumentWHERE

 

&

 

" ORDER BY LOWER(People.nameLastFirstMiddleInitial) ASC.

"

 

;

 

 

Seems like this should work. Obviously, I'm overlooking something. Any idea what that is?

 

Thanks,

Michael

Outcomes