Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Selecting multiple tables

Author  Topic 

punkrocker937
Starting Member

2 Posts

Posted - 2007-06-29 : 20:53:54
Let's say I have three tables: enrolled, student, course_section

They consist of:
enrolled - student_id, term, course_code
student - student_name, student_id
course_section - course-num, dept_abbr, course_code

I want to end up with one table consisting of student_name, term, dept_abbr, and course_num. In that order. I don't want student names to repeat and also would like to have it sorted by term within student name. Please help. Thanks.

Something like this:

STUDENT_NAME TERM DEPT_ABBR COURSE_NUM
------------------------------ ---- --------- ----------
Adams S07 BIOL 1505
S07 CSIS 2610
Davis X07 GEOG 2630
Edwards S07 GEOG 2630
X07 MATH 1548

jezemine
Master Smack Fu Yak Hacker

2886 Posts

Posted - 2007-06-29 : 21:04:42
smells like homework.

do you want to show us what sql you have so far?


elsasoft.org
Go to Top of Page

punkrocker937
Starting Member

2 Posts

Posted - 2007-06-29 : 21:20:35
I'm not sure how to start. Do I need to use joins?
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2007-06-30 : 00:02:39
yes. use INNER JOIN


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2007-06-30 : 00:12:12
Learn SQL
http://www.sql-tutorial.net/
http://www.firstsql.com/tutor.htm
http://www.w3schools.com/sql/default.asp


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -