General SQL Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsDatabasesGeneral SQL Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community 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 November 4th, 2003, 02:51 AM
tim tim is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jun 2002
Posts: 62 tim User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 12 m 9 sec
Reputation Power: 7
Send a message via ICQ to tim
PostgreSQL Sub-Select Query

I have the following 2 tables:

dbfp_dev=# select * from usrdtls_usrgrps;
usrdtls_usrgrps_id | userid | usergroupid
-------------------------+--- -----+-------------
1 | 1 | 1
2 | 4 | 5
3 | 5 | 5

dbfp_dev=# select userid, username, usertype from userdetails;
userid | username | usertype
---------+--------------+-----------
1 | admin | system
4 | melvin | affiliate
5 | jane | affiliate


------------------------------------------------------------------------------------

.....and I run this sub-select query statement:

dbfp_dev=# select userid from usrdtls_usrgrps where usergroupid='5' and userid in (select userid from userdetails order by username asc);
userid
--------
4
5


It returns to me the userid in the order 4, 5, meaning melvin, followed by jane. However I want the userids returned to be sorted by asc, meaning, jane, followed by melvin, which is 5 then 4.....NOT 4, then 5. What is wrong? Hope I made myself clear =D...any ideas please?
__________________
Beginner

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsDatabasesGeneral SQL Development > PostgreSQL Sub-Select Query


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 2 hosted by Hostway