Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7735551
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T07:31:49+00:00 2026-06-01T07:31:49+00:00

I am a beginner when it comes to using mysql queries embedded inside other

  • 0

I am a beginner when it comes to using mysql queries embedded inside other mysql queries using the IN statement.

I currently have this query:

SELECT DISTINCT BorName
FROM Borrower
WHERE BorId IN (
    SELECT Borrower.BorId
    FROM Loan
    WHERE Loan.BcId IN (
        SELECT BookCopy.BcId
        FROM BookCopy
        WHERE BookCopy.BtId In (
            SELECT BookTitle.BtId
            FROM BookTitle
            WHERE BookTitle.PubId In (
                SELECT Publisher.PubId
                FROM Publisher
                WHERE  `PubName` = CONVERT( _utf8 'Methuen' USING latin1 ) COLLATE latin1_swedish_ci
                )
            )
        )
    );

I am basically trying to find out if a borrower has borrowed a book from the publisher Methuen. I just cant seem to work out what is wrong, I have gone through each individual statement and they all seem to work just not the overall request with all of the IN statements.

Can anyone spot what is wrong?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T07:31:51+00:00Added an answer on June 1, 2026 at 7:31 am

    Like suggested, JOINs are a much cleaner, and likely a more efficient way to do this query as opposed to nested INs:

    SELECT DISTINCT b.BorName
    FROM 
        Borrower b
        JOIN Loan l ON l.BorId = b.BorId
        JOIN BookCopy bc ON bc.BcId = l.BcId
        JOIN BookTitle bt ON bt.BtId = bc.BtId
        JOIN Publisher p ON p.PubId = bt.PubID
    WHERE
        p.PubName = CONVERT( _utf8 'Methuen' USING latin1 ) COLLATE latin1_swedish_ci
    

    Additionally, I think there was a problem in your first sub-query:

    SELECT Borrower.BorId
    FROM Loan
    WHERE Loan.BcId IN...
    

    I believe should have been:

    SELECT Loan.BorId
    FROM Loan
    WHERE Loan.BcId IN...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm an absolute beginner when it comes to using both SWIG and lua, and
I currently have 3 ways to play audio within my app: Using AudioServicesPlaySystemSound for
Forgive my ignorance, but I am a beginner in java that comes from using
I'm a total beginner when it comes to computer languages, and was asked for
I am an absolute beginner when it comes to ActionScript and Flash. I am
I'm absolute beginner when it comes to mono for android . I've used following
I am a beginner when it comes to programming with Android/Java, and I am
I'm absolute beginner when it comes to mono for android . Referring to below
I'm a total beginner when it comes to neural networks. I've been wrestling with
Beginner level question Scenario: Have simple string cocantation tool, that I might expand later

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.