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 8490911
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T22:15:49+00:00 2026-06-10T22:15:49+00:00

I just learned you can stack SQL queries instead of running 4 different ones

  • 0

I just learned you can stack SQL queries instead of running 4 different ones and combining the data. So I’m read tutorials and stuff but still can’t figure this certain one out.

SELECT ID,
       (SELECT firstname
        FROM   user
        WHERE  ID = fundraiser.user_ID) AS firstname,
       (SELECT lastname
        FROM   user
        WHERE  ID = fundraiser.user_ID) AS lastname,
       (SELECT org_fund_id
        FROM   fundraiser
        WHERE  ID = fundraiser.ID)      AS org_fund_ID,
       (SELECT ref_ID
        FROM   fundraiser
        WHERE  ID = fundraiser.ID)      AS ref_ID
FROM   fundraiser
WHERE  1
ORDER  BY org_fund_ID ASC

Here’s the basic setup for the database/tables being called:
[fundraiser] – (ID, ref_ID, user_ID, org_fund_ID) and
[user] – (firstname, lastname)

Basically, I want to pull all of the fields from “fundraiser” from the database but get the corresponding “user.firstname” and “user.lastname” where “fundraiser.user_ID” = “user.ID”.

So it would come out something like this as a row:
fundraiser.ID, fundraiser.user_ID, fundraiser.ref_ID, user.firstname, user.lastname

I’ve tried like 30 different ways of writing this query and all have failed. The error I get is “#1242 – Subquery returns more than 1 row”.

Not sure how I can give you more information so you can visualize what I’m talking about, but I will provide whatever data I can.

Thanks in advance.

  • 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-10T22:15:51+00:00Added an answer on June 10, 2026 at 10:15 pm

    to select ALL columns:

    SELECT *
    FROM   fundraiser f
           INNER JOIN user u
                   ON u.ID = f.user_ID
    ORDER  BY f.ord_fund_id ASC;
    

    to select needed columns:

    SELECT 
        u.firstname,
        u.lastname,
        f.org_fund_id,
        f.ref_ID
    FROM fundraiser f 
    INNER JOIN user u ON u.ID = f.user_ID
    ORDER BY f.ord_fund_id ASC;
    

    this should be, what you need. See this Wikipedia page.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I just learned (the hard way) that Java Component s can only have one
I just learned the hard way that IntPtr.Zero cannot be compared to default(IntPtr). Can
As I just learned from this question , .NET regexes can access individual matches
I just learned about ThreadLocal this morning. I read that it should always be
I've just learned POI and find the HSSF is very simple to read and
I've just learned that we can iterate through all checkboxes in a document, but
I've just recently learned how jquery can access dynamically generated content, by placing a
I just learned about .delegate today, and I know I can be used for
I just learned, to my amazement, that foreign key constraints can be non-trusted. This
I have just learned that you can use a Thread pool for multi client

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.