How to resolve this problem?

Discussion in 'MySQL' started by indoforum, Mar 25, 2010.

  1. #1
    I have 2 tables. Staff and Branch.
    I want to list all of name on Staff which live in Branch in London.

    SELECT staffNo, fName, lName, branchNo
    FROM Staff
    WHERE branchNo=
    (SELECT branchNo
    FROM Branch
    WHERE city IN ("LONDON"));
    Code (markup):
    I am using MS. Access to test this query and I got error message:
    At most one record can be returned by this query.

    What's wrong? How to fix this query?

    Many thanks.
     
    indoforum, Mar 25, 2010 IP
  2. mnvlxxx

    mnvlxxx Peon

    Messages:
    47
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Try this:

    
    SELECT staffNo, fName, lName, branchNo
    FROM Staff
    WHERE branchNo=
    (SELECT branchNo
    FROM Branch
    WHERE city="LONDON" group by branchNo);
    
    Code (markup):
     
    mnvlxxx, Mar 25, 2010 IP
  3. killaklown

    killaklown Well-Known Member

    Messages:
    2,666
    Likes Received:
    87
    Best Answers:
    0
    Trophy Points:
    165
    #3
    SELECT staffNo, fName, lName, Staff.branchNo as branchNO
    FROM Staff LEFT JOIN Branch ON Branch.branchNo = Staff.branchNo
    WHERE city = 'LONDON'
    Code (markup):
     
    killaklown, Mar 25, 2010 IP
  4. indoforum

    indoforum Active Member

    Messages:
    493
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    80
    #4
    Thanks, but its not work.

    Thanks, its work.
     
    indoforum, Mar 25, 2010 IP