marthirial
IS-IT--Management
Here is the case, and sorry if I am asking something already answered but couldn't find what I need.
I have a table with three columns. by default by loading the page, this table will show the records sorted by date from newest to oldest.
ORDER BY sortvar DESC
where sortvar is a querystring for my field called date.
Now the issue I cannnot resolve is that if sortvar uses the querystring title, for example, the sort will be DESC again, meaning titles with first letter Z will be first and A will be last.
How do I write the ORDER BY so SQL knows that if sortvar is date_ it should go DESC but if it is title should go ASC.
Thanks and I will keep searching while I get any help.
I have a table with three columns. by default by loading the page, this table will show the records sorted by date from newest to oldest.
ORDER BY sortvar DESC
where sortvar is a querystring for my field called date.
Now the issue I cannnot resolve is that if sortvar uses the querystring title, for example, the sort will be DESC again, meaning titles with first letter Z will be first and A will be last.
How do I write the ORDER BY so SQL knows that if sortvar is date_ it should go DESC but if it is title should go ASC.
Thanks and I will keep searching while I get any help.