Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MYSQL 'order by' question & request for book suggestion

Status
Not open for further replies.

mysqlnovice

Programmer
Jan 24, 2004
2
US
I am writing a web application that uses a MYSQL database. I am comfortable with the straightforward SQL, but when I have to do anything out of the ordinary, I have to consult my book. I have purchased the MYSQL Bible. I have found the Bible series to be very good, but the MYSQL Bible seems to be an exception.

So I have three questions:

(1) What is the best MYSQL reference book for an SQL novice?
(2) When doing a SELECT, how do I reverse the ORDER BY (I am ordering by date, but I want the most recent dates first)?
(3) If I only want records with a date in the last 30 days, how do I say that in the WHERE clause?

Thank you very much for any assistance.

Mel
 
1. no idea, i only use the mysql.com docs, but then, i've been using sql since long before mysql was invented

you have a mysql "bible" and it doesn't answer the following two questions? whoa, i find that idea impossible to swallow

2. order by datefld desc

3. where datefld >= date_add(current_date, interval -30 day)



rudy
SQL Consulting
 
Thank you, Rudy. Now that I know the DESC keyword, I looked it up in the index of the MYSQL Bible. The index lists it once on page 225. I checked 224 - 226. No reference to the DESC keyword or to reversing the order in an ORDER BY statement. See what I mean about this book!

Best,

Mel
 
look up SELECT

it's gotta be there

i mean, heck, even the mysql.com docs page at gives the syntax as

[ORDER BY {unsigned_integer | col_name | formula}
[ASC | DESC] ,...]

and then says

"To sort in reverse order, add the DESC (descending)
keyword to the name of the column in the ORDER BY
clause that you are sorting by. The default is
ascending order; this may be specified explicitly
using the ASC keyword."

i'll be in my neighbourhood bricks&mortar bookstore later today, i'll have a look at this so-called "bible"

rudy
SQL Consulting
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top