Database Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsOther TechnologiesDatabase Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here
  #1  
Old April 7th, 2003, 07:19 PM
mcyphers mcyphers is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: columbia, md, usa
Posts: 1 mcyphers User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via Yahoo to mcyphers
SQL Statement help with MYSQL

I am new to MYSQL, fairly intermediate at SQL language. Here is my problem. I have an app. that displays a list of artists by the number of prints they have listed in our database



(eg. select artist_id, artist_lname, artist_fname from artist order by numberofprints DESC limit 100).



This statement grabs a list of the artist with the most prints in the database.



However, I need this statment to order by artistLastName when displayed in the browser.
The problem is I need to order these by the artist last name. Since MYSQL (3.23) doesn't allow embedded, or sub queries I don't know how to do this. The current SQL statement reads:
(select artistID, artistFirstName, artistLastName, numPrints from ap_artists ORDER by numPrints, artistLastName DESC LIMIT 100). THis gets the top 100 artists, but doesn't sort them by last name. Help.

Reply With Quote
  #2  
Old April 7th, 2003, 09:20 PM
superalloy superalloy is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Washington DC
Posts: 58 superalloy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
RE: SQL Statement help with MYSQL

Change:
select artistID, artistFirstName, artistLastName, numPrints from ap_artists ORDER by numPrints, artistLastName DESC LIMIT 100

to:

select artistID, artistFirstName, artistLastName, numPrints from ap_artists ORDER by artistLastName LIMIT 100

The ORDER BY statement determines the order, the DESC makes the order descending (Z-A). put the artistLastName column after the ORDER BY, and remove the Descending order

Reply With Quote
Reply

Viewing: Codewalkers ForumsOther TechnologiesDatabase Help > SQL Statement help with MYSQL


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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 On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway