Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Select query where it finds ids taking certain classes but not other classes

Status
Not open for further replies.

kernal

Technical User
Feb 27, 2001
415
US
table CLASS:

id subject course# section#

1 TEST 1 1
1 TEST_2 3 3

2 TEST 4 4
2 ART 1000 5


My query would need to find ids that have taken TEST or TEST_2 classes but not a non-TEST class so it would only retrieve id "1" since id "2" took an ART class.

I hope I gave enough information.

Thanks
 
Kernal,

Please post the code you have come up with so far.

[santa]Mufasa
(aka Dave of Sandy, Utah, USA)
“People may forget what you say, but they will never forget how you made them feel.
 
[bigsmile]Nice post Santa, I seem to recall that problem from one of my Oracle classes.

[profile]

To Paraphrase:"The Help you get is proportional to the Help you give.."
 
I don't have much in the select query only:

select * from class where subject like "TEST%" order by id, subject, course, section

Thanks
 
Kernal,

A functional narrative of your code, above, is:
[ul][li]Read the CLASS table.[/li]
[li]Return only rows that begin with the string, 'TEST'.[/li]
[li]Sort the results by ID, SUBJECT, COURSE, and SECTION[/li][/ul]

Could you please enhance just the functional narrative to do what needs to happen to produce the results you want. Don't worry about syntax; worry only about the logic you need to produce what you want. If you create the logic, then we can help with the SQL syntax.

[santa]Mufasa
(aka Dave of Sandy, Utah, USA)
“People may forget what you say, but they will never forget how you made them feel.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top