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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T20:56:56+00:00 2026-05-25T20:56:56+00:00

Notice that I’m calling and joining the same tables for my main query and

  • 0

Notice that I’m calling and joining the same tables for my main query and subquery.

Now my actually query is using many more subqueries like that.

Is there a way to call a subquery field from the main query thus eliminating the need to reuse the same join tables in the subqueries? I want to make it more efficient without sacrificing speed.

SELECT tb1.id, tb1.title,

(SELECT tb1.title 
FROM table1 AS tb1
JOIN table2 AS tb2 ON tb2.id = tb1.id 
LEFT JOIN table3 AS tb3 ON tb2.id = tb3.id 
WHERE tb1.id > '123' LIMIT 1) AS next

FROM table1 AS tb1
JOIN table2 AS tb2 ON tb2.id = tb1.id 
LEFT JOIN table3 AS tb3 ON tb2.id = tb3.id
WHERE tb1.id='123'
  • 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-05-25T20:56:57+00:00Added an answer on May 25, 2026 at 8:56 pm

    You can use a View to abstract that query.

    CREATE VIEW tbl_view AS 
    SELECT 
    tb1.id as id,
    tb1.title as title  
    FROM table1 AS tb1
    JOIN table2 AS tb2 ON tb2.id = tb1.id 
    LEFT JOIN table3 AS tb3 ON tb2.id = tb3.id
    

    The shorter query would be

    SELECT 
      id, 
      title,
      (SELECT title FROM tbl_view
      WHERE id > '123' LIMIT 1) AS next
    FROM 
      tbl_view
    WHERE id='123'
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I notice that I import many of the same imports into nearly every view
My question is: Notice that I am putting MvrId in many tables. What is
I notice that when using my touch-screen smartphone (no physical keyboard) that when an
I notice that NetBeans is warning me about using Thread.sleep() in a while loop
I notice that we can set the language for a form by using Xml:lang=en-US
Notice that for the given table below, the first row or the first many
I notice that some of the base applications in Android are using this little
I notice that StackOverflow has a views count for each question and that these
I notice that modern C and C++ code seems to use size_t instead of
I notice that there's frequently an aspnet_client folder under the standard IIS web folder

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.