p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


Go Back   p2p.wrox.com Forums > Database > SQL Language
I forgot my password Register Now
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
SQL Language SQL Language discussions not specific to a particular RDBMS program or vendor.

Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Language section of the Wrox p2p Programmer to Programmer discussion community. This is a community of more than 40,000 computer programmers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining our free Wrox p2p community you can post your own programming questions and respond to other programmers’ questions. Registered users also don't have to see the ads that are displayed to guests. Registration is fast, simple and absolutely free so please, join today!
Join today and post to win prizes! Post more to increase your chances of being Wrox’s top poster of the month.

Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old September 15th, 2009, 06:12 PM
Authorized User
Points: 107, Level: 2
Points: 107, Level: 2 Points: 107, Level: 2 Points: 107, Level: 2
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2007
Location: , , .
Posts: 22
Thanks: 0
Thanked 0 Times in 0 Posts
Default query

i have a table guys that i use to store stories
basically what i want is to retrieve the story_id,story_title.story_date from stories

and to load them in this form

story_Date
(example September 16,2009)
story_title
( example titleeeeeeeeeeeeeeeeeeeee 10:59 <- time the story was published (story_date is of type datetime)
.
.
.
.
then Story_date (example September 15,2009)
and all stories related to this date
.
.
then Story_date (might be September 10,2009)
and all stories related to this date
.
.
.
then Story_date (example September 8,2009)
and all stories related to this date


can i get my data in this format from sql so i can use it directly to load it in my pages

basically i could have got the top 4 dates from my table but i had a problem since i am saving the time with my date
select top 4 story_date from stories
returns
2009-15-09 10:45:34
2009-15-09 10:31:34
2009-15-09 10:20:34
2009-15-09 09:45:34

which is wrong coz i am looking the latest 4 days not the latest 4 entries

i hope some1 can help me out down here
i guess i need to use a stored procedure since i am gona do paging to the results
load a new date,keep 3 dates from previous query and remove the previous top date etc etc

please help me out guys

thanks in advance
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #2 (permalink)  
Old September 15th, 2009, 07:18 PM
Friend of Wrox
Points: 4,805, Level: 29
Points: 4,805, Level: 29 Points: 4,805, Level: 29 Points: 4,805, Level: 29
Activity: 50%
Activity: 50% Activity: 50% Activity: 50%
 
Join Date: Jun 2008
Location: Snohomish, WA, USA
Posts: 1,323
Thanks: 3
Thanked 70 Times in 69 Posts
Default

What database are you using? The answer depends *HEAVILY* on the type of database.

Getting the date-only from a datetime value is trivial in Access and MySQL but a pain in SQL Server.

It *looks* like you are using MySQL, given the format you listed your datetime values in, but...
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Output Query to txt file from SQL Query everest SQL Server 2005 4 November 22nd, 2007 01:49 AM
how to make a query from an existing query raport SQL Language 3 November 13th, 2006 08:59 PM
I solved insert query.now see this Update Query. amit_mande@yahoo.com VB.NET 2002/2003 Basics 2 September 21st, 2006 01:48 AM
Syntax error in query. Incomplete query clause. dispickle ADO.NET 3 April 16th, 2004 02:04 PM
Error on Make-Table Query In Union Query rylemer Access 1 August 20th, 2003 08:42 PM



All times are GMT -4. The time now is 02:19 AM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
© 2008 Wiley Publishing, Inc