Moron Posted February 12, 2009 Share Posted February 12, 2009 My query (abbreviated): $RESULTDS=mssql_query("SELECT M2.[hrYRAT], PA.[PSTU39], PA.[PSTU54], PA.[PSTU55], PA.[PSTU57] FROM MASTERL2 M2 LEFT JOIN PAYSTUBS_Archive PA ON PA.[PSTUB2]=M2.EMPNO WHERE PA.[PSTUB2] = '".$_SESSION['empcode']."' ORDER BY PA.[PSTU57] desc"); In the ORDER BY statement, I can remove the "desc" part and it makes no difference. The field it's ordering by is a date field in the format of 20081115, 20090110, etc... (year, month, day). Thanks! EDIT: I want the most current date on top of the list, thus the "desc" part. Link to comment https://forums.phpfreaks.com/topic/144909-solved-why-doesnt-my-order-by-____-desc-work/ Share on other sites More sharing options...
aebstract Posted February 12, 2009 Share Posted February 12, 2009 It's ordering by PA.[PSTU57] in a descending order, change it to ASC and it will flip the order. You can also change PA.[PSTU57] to something else if you would like to order by another column in your table. Link to comment https://forums.phpfreaks.com/topic/144909-solved-why-doesnt-my-order-by-____-desc-work/#findComment-760417 Share on other sites More sharing options...
Moron Posted February 12, 2009 Author Share Posted February 12, 2009 It's ordering by PA.[PSTU57] in a descending order, change it to ASC and it will flip the order. You can also change PA.[PSTU57] to something else if you would like to order by another column in your table. I tried it and it makes no difference, either using ASC or removing it completely. It's like it's not recognizing either ASC or DESC for some reason. Link to comment https://forums.phpfreaks.com/topic/144909-solved-why-doesnt-my-order-by-____-desc-work/#findComment-760418 Share on other sites More sharing options...
aebstract Posted February 12, 2009 Share Posted February 12, 2009 Is PA.[PSTU57] a valid column name? Is it suppose to have the []? Link to comment https://forums.phpfreaks.com/topic/144909-solved-why-doesnt-my-order-by-____-desc-work/#findComment-760420 Share on other sites More sharing options...
Moron Posted February 12, 2009 Author Share Posted February 12, 2009 It's fixed. I forgot to adjust this in my second query, the one that actually pulls the results. It explains my username. Link to comment https://forums.phpfreaks.com/topic/144909-solved-why-doesnt-my-order-by-____-desc-work/#findComment-760421 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.