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 August 16th, 2004, 10:56 PM
markshen2004 markshen2004 is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Aug 2004
Posts: 2 markshen2004 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
a stored procedure question?

I have two tables.the structures like this

table one (total student table)

id student_id
1 10
2 11
3 12
4 13
5 14

table two (graduated student table)

id student_id
1 10
2 12


I want to get all of the student id who have not graduated.
that is the records in table one but not in table two.the
result like this.

id student_id
2 11
4 13
5 14

I want to write a stored procedure to do it.please give me a idea how to
write the stored procedure.

Thanks a lot.

Reply With Quote
  #2  
Old August 19th, 2004, 05:28 AM
Kris_Vanherck's Avatar
Kris_Vanherck Kris_Vanherck is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Location: Belgium, Antwerp
Posts: 177 Kris_Vanherck User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 24 sec
Reputation Power: 5
SELECT id, student_id
FROM table1
WHERE student_id NOT IN (SELECT student_id FROM table2)

note: view would be better suited for this kind of query

Reply With Quote
Reply

Viewing: ASP Free ForumsDatabaseMicrosoft SQL Server > a stored procedure question?


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 5 hosted by Hostway