|
| Register now to interact with over 11,000 members! Registered users have Posting Privileges, free access to Private Messaging, Email Notifications and more. |
|
|||||||
![]() |
|
|
Thread Tools | Search this Thread |
|
|
#1 |
|
Posts: n/a
|
Sorting after getting MYSQL Results
Hello,
I have a database of Books. I currently use a SQL to get the 4 newest additions, and then another SQL to list in alphabetic order by title All books. My problem is that the 4 newest books also show up in the alpha list. I would like to do away with the second SQL statement, and make my alpha list from the entries remaining from the first SQL statement. How can I do this? How do I sort the remaining results to alpha? Thanks ! |
|
|
#2 |
|
Posts: n/a
|
No one's got any ideas?
|
|
|
#3 |
|
Older not wiser
Join Date: Nov 2003
Location: Calgary, AB
Posts: 2,473
Reputation: 205
|
This would work fine as a subquery (not available until Powweb upgrades to MySQL 4.1)
But since you have to run the two queries anyways, it kind of defeats the purpose. You might as well read the results of the first query into a comma-delimited string - then use that to exclude titles from the second query. Don't know how much PHP you have under your belt, but maybe a little pseudo-code will help for now. PHP Code:
Loop to build comma-delimited list of titleID from $query1 results ... $lasttitles = "12,11,10,9" PHP Code:
|
|
|
|
|
#4 |
|
Posts: n/a
|
>> NOT IN
That did the trick, never heard of that one. Thanks ! |
![]() |
| Thread Tools | Search this Thread |
|
|