Results 1 to 2 of 2
  1. #1
    Join Date
    May 2012
    Posts
    132

    Unanswered: a query with a combination criteria

    We have the following table.
    Code:
    ID   studentname    lectureplace       lecturesubject
    1         jack           A             Biology    
    2         steve          A             politics    
    3         jack           B             math    
    4         steve          A             math    
    5         jack           B             politics    
    6         joe            A             politics    
    .          .             .                .
    .          .             .                .
    154       Jane           B            Geography
    We need a query to implement two criteria to extract the following records:
    1- Show lectureplace A AND politics lecturesubject
    2- Show only those with lectureplace B regardless of the subject
    In case the query is run we will have the following result:
    Code:
    ID   studentname    lectureplace       lecturesubject
    2         steve          A             politics    
    3         jack           B             math    
    5         jack           B             politics    
    6         joe            A             politics    
    .          .             .                .
    .          .             .                .
    154       Jane           B            Geography

    Thank you very much
    ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
    I asked god to please give me everything to enjoy the life, God said: i gave you the life to enjoy everything.

  2. #2
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    So its down to your where clause.
    you need to sub clauses linked with an or. eg:-
    Code:
    where something = 'blah' or (something = 'tarrah' and somethingelse in ( 'hoot', 'toot'))
    order by required, column, order
    I'd rather be riding on the Tiger 800 or the Norton

Posting Permissions

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