Go Back   Tech Support Forum > The IT Pro > Programming

MS SQL Select Data From Multiple Tables

This is a discussion on MS SQL Select Data From Multiple Tables within the Programming forums, part of the Tech Support Forum category. Greets! Before I get started, I just want to make it clear that I did search for the answer to


Reply
 
Thread Tools Search this Thread
Old 06-14-2011, 12:22 PM   #1
Registered Member
 
Join Date: Jun 2011
Posts: 2
OS: NT 6.1 Pro x64


Pencil

Greets! Before I get started, I just want to make it clear that I did search for the answer to this question on my own. I could not understand or use the tutorials I did happen to find. I think I just need some basic clarification.

I am running Microsoft SQL Server 2008 R2. I have two tables I need to select data from and display together. One table is called "Courses". The other is called "Sessions".

There is only one common field these tables share, the "Course ID".

I would like to display all the data from both tables in a format that combines the two tables based on the "Course ID". There may be multiple rows showing the same "Course ID", but different "Session IDs" and "Locations".

Could someone please help me understand the syntax of the SELECT command I need?

Much thanks!

__________________
NestleCrunch is offline   Reply With Quote
Old 06-15-2011, 07:17 AM   #2
Registered Member
 
Join Date: Apr 2010
Posts: 236
OS: Windows 7

My System


This is actually quite funny, I've been trying to figure this out for a while and I just did.

If I'm not mistaken it's something like:
Code:
SELECT C.*, S.*
FROM Courses C, Sessions S
WHERE C.[Course ID] = S.[Course ID]
Or for an actual join:
Code:
SELECT C.*, S.*
FROM Courses C JOIN Sessions S
ON C.[Course ID] = S.[Couse ID]
They're both equally as small (in lines) so it's really your choice.

__________________
Crockeo is offline   Reply With Quote
Old 06-15-2011, 08:00 AM   #3
Registered Member
 
Join Date: Jun 2011
Posts: 2
OS: NT 6.1 Pro x64



Hey! Thanks for the reply! It took me a while to get my head around this. I hope other people can stumble across this and find it useful too!

My app is now working the way I needed it to. I also found this page to be useful in understanding the join command:

SQL Server Basics: Select from multiple tables using INNER JOIN
__________________
NestleCrunch is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Similar Threads
Thread Thread Starter Forum Replies Last Post
Infections / Malware / rundll32.exe error
My computer was last used by someone to download games and watch videos on the internet. The next thing I know, there were pop-ups. I am constantly getting these fake spyware removal pop ups. I tried going into control panel/add-remove programs and I get a 'rundll32.exe' error message. I used...
6one9 Resolved HJT Threads 54 05-16-2011 06:06 AM
I know something is wrong..part two...
I previously posted a thread titled "I know something is wrong" but I came back and the thread is closed. Not sure why...but this is what it said. I just have no idea what it could be. I've posted about issues with this computer before but I thought I had things taken care of. Now, it's...
CleverSleazoid Windows XP Support 13 05-01-2011 01:55 PM

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is on
Smilies are on
[IMG] code is on
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off


Post a Question


» Site Navigation
 > FAQ
  > 10.0.0.2


All times are GMT -7. The time now is 07:48 AM.


Copyright 2001 - 2014, Tech Support Forum

Windows 7 - Windows XP - Windows Vista - Trojan Removal - Spyware Removal - Virus Removal - Networking - Security - Top Web Hosts