|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
SQL Table Joins
I have 2 tables Users, Groups.
Users has 3 fields, userid,username,createddatetime Groups has 3 fields, Groupid,groupname,createddatetime I want to display all users and all groups together on the same page sorted by groupid/name/or datetime. Is this acheivable thru' a SP or SQL Query ? or should i get both separately and do my own sorting. Any help is appreciated. Thanks |
|
#2
|
||||
|
||||
|
Hi,
you need a common field to do a inner join, best bet would be to use two recordsets. hope this helps
__________________
Look! Its a ShemZilla ![]() ![]()
|
|
#3
|
||||
|
||||
|
If you really want to get all of the users and all of the groups in the same recordset you can. I assume that you want the contents of userid and groupid in the same column and the same with name and date. If so, you can just alias the column names so that they are the same and union the two together:
select * from (select userid as uid, username as aname, createddatetime from users union select groupid as uid, groupname as aname, createddatetime from groups) order by aname (or uid or createddatetime) |
![]() |
| Viewing: ASP Free Forums > Database > Microsoft SQL Server > SQL Table Joins |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|