If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ANSI SQL > How do I create and AND Where clause?

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 05-12-02, 20:35
bob_moran bob_moran is offline
Registered User
 
Join Date: May 2002
Location: NJ in USA
Posts: 1
How do I create and AND Where clause?

Hello,

I have a table that has rows of student_id's and class_codes.

How do I SELECT people that have taken multiple classes?

If I say

WHERE class_code = '1' AND class_code = '2' AND class_code = '3'

No rows get returned because no single row could have all three values in it.

I think I need some sort of nested SELECT statment, or VIEW, but what do I know?!

Thanks in advance,

Bob Moran
Reply With Quote
  #2 (permalink)  
Old 05-13-02, 05:35
alligatorsql.com alligatorsql.com is offline
Registered User
 
Join Date: Jul 2001
Location: Germany
Posts: 189
Hello,

if you need only the student identifier than use something like this:

select student, count(1) from table group by username
having count(1) > 1

Hope that helps

Manfred Peter
(Alligator Company)
http://www.alligatorsql.com
Reply With Quote
  #3 (permalink)  
Old 05-28-02, 04:35
Gyro Gyro is offline
Registered User
 
Join Date: May 2002
Posts: 15
If you would like to get the student id and names who have multiple classes.

select table2.student,table1.name from table1 inner join
(select student from table2 group by student
having count(student) > 1) as table2 on table2.student=table1.student

whereas:
table1 = student master file
table2 = enrollment transaction file
student = unique student id
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On