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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T04:17:16+00:00 2026-05-19T04:17:16+00:00

HI i want to get the value of the variable from the main query

  • 0

HI i want to get the value of the variable from the main query inside the sub query

SELECT t1.*,sq.*,count(distinct(t4.col1)) as count,
FROM t1 LEFT OUTER JOIN( 
                         SELECT t2.col1,
                                t2.col2,
                                t2.col3 
                          FROM t2 
                          WHERE   t2.col1=t1.col1            
                          ORDER BY t2.col2 DESC, t2.col1 DESC
                        ) as sq 
         ON sq.col1=t1.col1  
LEFT OUTER JOIN t3 ON t3.col1=t1.col4 
LEFT OUTER JOIN t4 ON t4.col1=t1.col4 
WHERE t3.col2=x 
GROUP BY t1.col3 
LIMIT 15

How do i get the value of the variable t1.col1 inside the subquery sq when I am joining it on the same column??

  • 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-19T04:17:16+00:00Added an answer on May 19, 2026 at 4:17 am

    You can’t but following should return equivalent results as the query you’ve posted.

    SELECT  t1.col3            
    FROM    t1 
            left outer join ( 
              select  t2.col1
                      ,t2.col2
                      ,t2.col3 
                      ,t2.col4
              FROM    t2 
            ) as sq on sq.col1 = t1.col1 
                       AND sq.col4 = t1.col1
    where   t1.col2 = x 
    group by 
            t1.col3 
    limit 15
    

    Note: the original query you’ve posted contains a few syntax errors.

    • select * with group by
    • order by in a subselect
    • using the outer select in the subselect (your question)
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i bascially want to get the value of a variable from the codebehind to
I'm trying to get a value from a variable inside some files, here is
I have a string containing the variable name. I want to get the value
I want to get the value from an array thats in a while fetchrow..
Basically I want to get the value of a textbox which is to select
I want to get value in a date picker and add to textfield_date..I used
I want to get the value of div using webdriver and not Selenium For
I want to get the value of my integer array, at an index. The
i want to get the value of this td my code function check() {
I have a RadioGroup rg1 and I want to get the value of the

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.