|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this 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
|
|||
|
|||
|
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 |
![]() |
| Viewing: Dev Articles Community Forums > Databases > General SQL Development > PostgreSQL Sub-Select Query |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|