Wrox Programmer Forums
|
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Dreamweaver (all versions) section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 7th, 2005, 11:33 AM
Authorized User
 
Join Date: May 2005
Posts: 57
Thanks: 0
Thanked 0 Times in 0 Posts
Default Most recent entry in a table?

Quick and probably easy question for someone.

I am trying to setup a recordset in dreamweaver that selects the row with the most recent date. Hope that made sense - I have had some problem getting dreamweaver to do it.

I have used this as sql:

select *
From table
Where date=MAX(date_stored)

Anyway - it isn't working at all - seems really simple. I also tried using:
select top 1 *
From table
order by date DESC

this did not work because it didn't like the order by.

Any help is appreciated.

Chris

 
Old June 7th, 2005, 12:07 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Your last query should work theoretically. However, date is a reserved word in some databases.

Either rename the column to something like DateAdded or whatever its purpose is or put the name in []:

SELECT TOP 1 * FROM table ORDER BY DateAdded DESC

or

SELECT TOP 1 * FROM table ORDER BY [date] DESC


HtH,

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
 
Old June 7th, 2005, 12:54 PM
Authorized User
 
Join Date: May 2005
Posts: 57
Thanks: 0
Thanked 0 Times in 0 Posts
Default

DOH!

I was kicking myself last night over this.

I had named the field "date stored" originally - after trying a bunch of things last night I changed it to date_stored - but didn't retry my first sql statement. It works well now.

Thanks as always Imar,

Chris

 
Old June 7th, 2005, 02:46 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

You're welcome.

Out of curiosity, what ever happened to your survey? Did that work out as planned?

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
While typing this post, I was listening to: Radian by Air (Track 5 from the album: 10 000hz legend) What's This?
 
Old June 8th, 2005, 09:09 AM
Authorized User
 
Join Date: May 2005
Posts: 57
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Imar -

The survey is alive and kicking! It runs through July 8th - no gliches or lag as far as I know. Luckily - it has been more of a trickle of people than a flood - maybe a few hundred people a day versus 5000 at once. I really apreciate your help with everything (as I am sure many people her do!)

I am working on a new project for my wife now - a sample tracking system - (I am sure I will be posting a few more time with questions!)


Thanks again,

Chris






Similar Threads
Thread Thread Starter Forum Replies Last Post
Most Recent Date Ludgero SQL Server ASP 1 August 29th, 2006 12:48 PM
Edit-add new entry to an acces table from word matpen Access 4 January 5th, 2006 06:30 PM
How to get the most recent value from a column method Access 0 July 3rd, 2005 03:32 PM
New entry in front of table? Mantis MySQL 0 March 21st, 2005 08:40 PM
Most recent ID Colonel Angus SQL Server 2000 6 March 31st, 2004 09:54 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.