Microsoft SQL Server
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsDatabaseMicrosoft SQL Server

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old April 8th, 2005, 08:35 AM
abc123 abc123 is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Apr 2005
Posts: 1 abc123 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 14 m 14 sec
Reputation Power: 0
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

Reply With Quote
  #2  
Old April 8th, 2005, 08:55 AM
nofriends's Avatar
nofriends nofriends is offline
Senior Water Wizard
ASP Free God 11th Plane (10000 - 10499 posts)
 
Join Date: Aug 2004
Location: Cape Town, RSA
Posts: 10,186 nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)  Folding Points: 107805 Folding Title: Super Ultimate Folder - Level 1Folding Points: 107805 Folding Title: Super Ultimate Folder - Level 1Folding Points: 107805 Folding Title: Super Ultimate Folder - Level 1Folding Points: 107805 Folding Title: Super Ultimate Folder - Level 1Folding Points: 107805 Folding Title: Super Ultimate Folder - Level 1Folding Points: 107805 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 3 Months 2 Weeks 2 Days 7 h 36 m 24 sec
Reputation Power: 699
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



Reply With Quote
  #3  
Old April 9th, 2005, 02:22 AM
gregory.owen@hp's Avatar
gregory.owen@hp gregory.owen@hp is offline
Maniac
ASP Free Novice (500 - 999 posts)
 
Join Date: Sep 2003
Location: Sweet Home, Oregon
Posts: 548 gregory.owen@hp User rank is Sergeant (500 - 2000 Reputation Level)gregory.owen@hp User rank is Sergeant (500 - 2000 Reputation Level)gregory.owen@hp User rank is Sergeant (500 - 2000 Reputation Level)gregory.owen@hp User rank is Sergeant (500 - 2000 Reputation Level)gregory.owen@hp User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 3 Days 4 h 37 m 8 sec
Reputation Power: 14
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)

Reply With Quote
Reply

Viewing: ASP Free ForumsDatabaseMicrosoft SQL Server > SQL Table Joins


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 4 hosted by Hostway
Stay green...Green IT