Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 SORTING

Author  Topic 

jennifer_ann
Starting Member

8 Posts

Posted - 2006-04-10 : 17:21:08
Ok this is what I have
$query = $query = "SELECT date, file name FROM comment WHERE file name ='', AND CorS='C', AND Approved='Y', ORDER BY file name DESC";


But what I want is to return all results based on the file name from the most recent to the oldest. Can anyone help????

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2006-04-10 : 17:23:30
ORDER BY [date] DESC

Tara Kizer
aka tduggan
Go to Top of Page

jennifer_ann
Starting Member

8 Posts

Posted - 2006-04-10 : 19:22:13
I should have clarified better. My file name is named by the date people left it. So how do I order by that?
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2006-04-10 : 19:54:40
What is the format of the filename ? is it in a certain fixed format ?



KH


Go to Top of Page

jennifer_ann
Starting Member

8 Posts

Posted - 2006-04-10 : 20:13:41
What everyone has said has helped me out, and I've made progress on my queries, however they still are not what I need and I'm not sure how to fix it. So here goes. I have a table that has
UserID, date, name, yrleft, cityorigin, countryorigin, yrarrival, cityarrival, starrival, email, address, city, state, zip, aorv, filename, and approved

Mandatory information includes the date, yrleft, cityorigin, countryorigin, yrarrival, cityarrival, starrival, and aorv. The filename is named with a timestamp as to when they left their recording or comment.

I need to run a query by dates from (1850-1950) so whatever date they put in, as long as it is within that time period, that it will return the results. I want to display the earliest date first. I want the results to return all the mandatory information. And approved must = Y

This is what I've gotten so far

PHP Code:
$query = $query = "SELECT Userid, date, yrleft, cityorigin, countryorigin, yrarrival,
cityarrival, statearrival, filename FROM Story WHERE approved = 'Y' AND ORDER by date ASC



Could someone tell me why this still isn't working? I need

Searches ==== sort based on search type: Dates - descending
returns....all required fields except name...include Id and filename

Go to Top of Page

Srinika
Master Smack Fu Yak Hacker

1378 Posts

Posted - 2006-04-10 : 20:26:38
$query = "SELECT Userid, date, yrleft, cityorigin, countryorigin, yrarrival, cityarrival, statearrival, filename FROM Story WHERE approved = 'Y' AND ORDER by date ASC

-- ASC is Default
-- If u want Descending order u have to provide DESC and not ASC or not just leave it
-- From ur earlier post date should be --> [file name]
-- Ur first query and last query differs
-- Ur End of String Quotation is missing

So ur probable query should be something like

$query = "SELECT Userid, date, yrleft, cityorigin, countryorigin, yrarrival, cityarrival, statearrival, filename
FROM Story
WHERE approved = 'Y' ORDER by [file name] DESC"





Srinika
Go to Top of Page

jennifer_ann
Starting Member

8 Posts

Posted - 2006-04-10 : 22:08:49
Thank you very much! you all have been such a big help
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-04-11 : 01:26:28
Learn SQL
http://www.sql-tutorial.net/
http://www.firstsql.com/tutor.htm
http://www.w3schools.com/sql/default.asp


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -