Forums
This topic is locked
Order By DATE and SUBCAT
Posted 15 Aug 2002 13:43:53
1
has voted
15 Aug 2002 13:43:53 John Gallagher posted:
Hi,I have a newspaper running on asp, when a user picks a Category (maincat) he is then taken to a detail page filtered by a Form Variable on maincat.
the results are ordered by date but now my clients want the results to be ordered by subcat too.
Here's what I want it to look like.
I pick Business as the main cat.
>>> to detail page,
<b>Business</b> (maincat)
Story 1 -- date: 01-01-2002
subcat - national
Story 2 -- date: 01-01-2002
subcat - national
Story 3 -- date: 01-01-2002
subcat - Internetional
Story 4 -- date: 01-01-2002
subcat - Internetional
Here is the SQL -
SELECT *
FROM article
WHERE maincat = 'MMColParam'
ORDER BY dateposted DESC
Could i use ORDER BY dateposted DESC AND datedposted
Thanks
Later,
Webcrafty
Replies
Replied 15 Aug 2002 16:19:09
15 Aug 2002 16:19:09 Vince Baker replied:
To filter by two fields add this to your sql:
ORDER BY Field1 DESC, Field2 ASC
You can order by as many as your want, just add a comma and then the next field name followed by ASC or DESC for ascending or descending.
ORDER BY Field1 DESC, Field2 ASC
You can order by as many as your want, just add a comma and then the next field name followed by ASC or DESC for ascending or descending.
Replied 15 Aug 2002 17:09:30
15 Aug 2002 17:09:30 John Gallagher replied:
Thanks,
If I order the categories and subcategories like you say that will work fine.
Next I need to have a menu on that page that catches the maincat coming from the form variable and display a list of subcategories in that cat.
This will be used to link to the part of the page here each subcat starts, like named anchors. Maybe I'm getting ahead of myself here and this can't be done but if any one has any ideads.
Cheers
Later,
Webcrafty
Edited by - webcrafty on 15 Aug 2002 17:10:52
If I order the categories and subcategories like you say that will work fine.
Next I need to have a menu on that page that catches the maincat coming from the form variable and display a list of subcategories in that cat.
This will be used to link to the part of the page here each subcat starts, like named anchors. Maybe I'm getting ahead of myself here and this can't be done but if any one has any ideads.
Cheers
Later,
Webcrafty
Edited by - webcrafty on 15 Aug 2002 17:10:52