I have the following statement:
$query = "SELECT * FROM aprstrack WHERE callsignSSID = 'VE9SC-9' order by reporttime desc limit 30 ";
It works but I am feeding the results to a xml file that needs the order reversed to what is displayed.
The display looks like this:
<?xml version="1.0" ?>
- <markers>
<marker call="VE9SC-9" lat="46.1088" lng="-64.8708" datetime="2012-01-20 20:26:33" course="" Speed="28" alt="" Icon="/P" />
<marker call="VE9SC-9" lat="46.1038" lng="-64.8633" datetime="2012-01-20 20:25:23" course="" Speed="26" alt="" Icon="/P" />
<marker call="VE9SC-9" lat="46.1038" lng="-64.8625" datetime="2012-01-20 20:25:19" course="" Speed="16" alt="" Icon="/P" />
<marker call="VE9SC-9" lat="46.1037" lng="-64.862" datetime="2012-01-20 20:25:11" course="" Speed="10" alt="" Icon="/P" />
<marker call="VE9SC-9" lat="46.1035" lng="-64.8622" datetime="2012-01-20 20:25:05" course="" Speed="14" alt="" Icon="/P" />
<marker call="VE9SC-9" lat="46.0978" lng="-64.86" datetime="2012-01-20 20:24:18" course="" Speed="18" alt="" Icon="/P" />
<marker call="VE9SC-9" lat="46.0943" lng="-64.8407" datetime="2012-01-20 20:21:40" course="" Speed="40" alt="" Icon="/P" />
<marker call="VE9SC-9" lat="46.0977" lng="-64.8178" datetime="2012-01-20 20:19:08" course="" Speed="12" alt="" Icon="/P" />
</markers>
The newest being listed on the top, what I need is the oldest listed on the top.
I have tried desc & ASC but that will not work what needs to be done ? I have looked on-line and I can not find an answer.
Thanks
Stephen
MySQL does the ordering first and then limits the results. That is why you would get the 30 oldest results. You need to do a subquery such that ordering happens after you have pulled the 30 newest records: