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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T09:40:40+00:00 2026-05-23T09:40:40+00:00

I have written a query which joins 3 tables where i need to inner

  • 0

I have written a query which joins 3 tables where i need to inner join 2 tables and then inner join the whole result set with another join.

The query is as follows:

SELECT  R.ID,
        R.Title,
        R.Requirement_Text,
        R.Req_Owner,
        D.desname,
        D.team,
        D.stage,
        D.comm 
FROM Req R 
        LEFT JOIN 
        (
            SELECT  d1.ID AS 'id',
                    d1.designername AS 'desname',
                    d1.teamname AS 'team',
                    s.stage AS 'stage',
                    s.comments As 'comm' 
            FROM descomments d1 
                    LEFT JOIN stagecomments s ON d1.ID = s.ID 
                                                 AND d1.designername = s.designername
        ) D ON R.ID = D.id
WHERE R.ProjectID = 'STE 11.2' 
ORDER BY R.Priority

But i am getting following error:

com.mysql.jdbc.exceptions.MySQLSyntaxErrorException: You have an error in your SQL syntax.  Check the manual that corresponds to your MySQL server version for the right syntax to use near 'SELECT d1.ID AS 'id',d1.designername AS 'desname',d1.teamname A
  • 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-23T09:40:41+00:00Added an answer on May 23, 2026 at 9:40 am

    You don’t need the ‘descomments’ after the first left join.. you’re actually joining to D, which is the result of your sub-join..

    SELECT 
      R.ID,
      R.Title,
      R.Requirement_Text,
      R.Req_Owner,
      D.designername,
      D.teamname,
      s.stage,
      s.comments 
    FROM Req R LEFT JOIN descomments D ON R.ID=D.id
    LEFT JOIN stagecomments s ON D.ID=s.ID AND D.designername=s.designername
    WHERE 
      R.ProjectID='STE 11.2' 
    ORDER BY R.Priority
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have written a query which involves joins and finally returns the below result,
I have a Complex SQL Query which is written with lot many Joins and
I have a complicated query written on SQL Server 2000 which in part contains
Ok. I have my query written finally for my php file (which will write
I have written a query which is a composite query like one update query
I have a query which returns to me results as follows: Race | Candidate
I have the following MySql query: select t1.* from Table1 t1 inner join Table2
I have a query which involves 2 tables 'Coupons' and 'CouponUsedLog' in SQL Server,
I have written a query which works great on my local SQL Server 2005.
I have written this query which returns a users friends and the friends on

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.