Results 1 to 3 of 3
  1. #1
    Join Date
    May 2002
    Location
    NJ in USA
    Posts
    1

    Unanswered: 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

  2. #2
    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

  3. #3
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •