homepage Welcome to WebmasterWorld Guest from 54.235.61.62
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / Databases
Forum Library, Charter, Moderators: physics

Databases Forum

    
How to output a query subset
I want to pull in the table once, and output it in several different ways
RevoltPuppy




msg:4400542
 3:52 pm on Dec 22, 2011 (gmt 0)

Hello, I have a question about outputting a query subset.

What I would like to do is select the whole table, and then output it based on date.

Right now I'm doing several different queries to select from each year, which seems somewhat inefficient.

So, ideally, my output would look something like this:

[Select all press release data from the table.]
2011
[Output press releases for the year 2011.]
2010
[Output press releases for the year 2010.]
2009
[Output press releases for the year 2010.]

 

Dijkgraaf




msg:4400656
 9:20 pm on Dec 22, 2011 (gmt 0)

It sounds like you might just want to order by the field that holds the year/date of publication in descending.
e.g ORDER BY publicationdate DESC
Then loop through all the records selected and when the year in the data changes create the break or heading or whatever you want.

RevoltPuppy




msg:4400677
 9:57 pm on Dec 22, 2011 (gmt 0)

Yes, that sounds like what I would like to do. How would I set up the loop to detect the change in the year?

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Databases
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved