|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
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
|
|||
|
|||
|
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. |
|
#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 |
![]() |
| Viewing: Codewalkers Forums > Other Technologies > Database Help > SQL Statement help with MYSQL |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|
|
|