Skip to main content
Known Participant
May 11, 2009
Question

how to fix this error in db

  • May 11, 2009
  • 2 replies
  • 1346 views

Error Executing Database Query. [Macromedia][SQLServer JDBC Driver][SQLServer]A constant expression was encountered in the ORDER BY list, position 1.       Hi i dont what is this error and how to fix this type of error :  here is the code : order by loc.zone_no, Due_Item_Store_tbl.sto_no, Due_Item_tbl.due_title order by Due_Priority_tbl.name, loc.zone_no, Due_Item_Store_tbl.sto_no, Due_Item_tbl.due_title order by Status, loc.zone_no, Due_Item_Store_tbl.sto_no, Due_Item_tbl.due_title order by Due_Item_tbl.due_title, loc.zone_no, Due_Item_Store_tbl.sto_no order by Due_Priority_tbl.name, Due_Item_tbl.due_title, loc.zone_no, Due_Item_Store_tbl.sto_no order by Status, Due_Item_tbl.due_title, loc.zone_no, Due_Item_Store_tbl.sto_no

This topic has been closed for replies.

2 replies

May 12, 2009

Like Dan mentions, you should only have one ORDER BY. If you want to have your query ordered by more than on column, do this:

ORDER BY column1, column2, column3


column1 gets precedence, then column2, etc.

cfnewAuthor
Known Participant
May 12, 2009

i had some <cfif> statements for these all order by statements

cfnewAuthor
Known Participant
May 12, 2009

i had like this in the query

<cfif orderbys is "1">order by loc.zone_no, Due_Item_Store_tbl.sto_no, Due_Item_tbl.due_title</cfif>
<cfif orderbys is "2">order by Due_Priority_tbl.name, loc.zone_no, Due_Item_Store_tbl.sto_no, Due_Item_tbl.due_title</cfif>
<cfif orderbys is "3">order by Status, loc.zone_no, Due_Item_Store_tbl.sto_no, Due_Item_tbl.due_title</cfif>
<cfif orderbys is "4">order by Due_Item_tbl.due_title, loc.zone_no, Due_Item_Store_tbl.sto_no</cfif>
<cfif orderbys is "5">order by Due_Priority_tbl.name, Due_Item_tbl.due_title, loc.zone_no, Due_Item_Store_tbl.sto_no</cfif>
<cfif orderbys is "6">order by Status, Due_Item_tbl.due_title, loc.zone_no, Due_Item_Store_tbl.sto_no</cfif>

Inspiring
May 12, 2009

the words "order by" should only show up once in a query.  What you posted has them at least three times.