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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T22:18:53+00:00 2026-06-12T22:18:53+00:00

select t1.table1 from table1 as t1 where t1.column1 in ( select t2.column2 from table2

  • 0
select t1.table1 from table1 as t1
where t1.column1 
in 
(
    select t2.column2 from table2 as t2 
    join 
    table3 as t3  on t2.column1=t3.column1 
    where t3.columnx=5
);

Above is the mysql query i am firing. Wanted some data from the subquery tables also.

For example say columnxy from table t2.

query that fails

select t1.table1,t2.columnxy from table1 as t1
where t1.column1 
in 
(
    select t2.column2 from table2 as t2 
    join 
    table3 as t3  on t2.column1=t3.column1 
    where t3.columnx=5
);

If i add them with select of the outer query gives error “unknown column” which does make sense.

Is the right way or should rewrite query with joins?

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

    Rewrite the query with joins:

    SELECT t1.table1, t.columnxy
    FROM   table1 AS t1 JOIN (
      SELECT t2.column2, t2.columnxy
      FROM   table2 AS t2 JOIN table3 AS t3 USING (column1)
      WHERE  t3.columnx = 5
    ) t ON t1.column1 = t.column2
    

    Or:

    SELECT t1.table1, t2.columnxy
    FROM   table1 AS t1
      JOIN table2 AS t2 ON t1.column1 = t2.column2
      JOIN table3 AS t3 ON t2.column1 = t3.column1
    WHERE  t3.columnx = 5
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Original Query I'm trying to rewrite: SELECT Table1.* FROM Table1 INNER JOIN Table2 ON
I tried doing this but it failed. SELECT table2.ID, table1.* FROM table2 LEFT JOIN
I've seen people writing the following query SELECT column_name(s) FROM table_name1 LEFT JOIN table_name2
Select Column1 From Table Where @Variable Like '%' + Column2 + '%' Doesn't seem
I have the query to select some columns from two tables, which must contain
insert into tableA (column1) select min(tableC.column1) from tableB inner join tableC on (tableC.coumn2 =
I have a query SELECT * FROM table1 WHERE documentId in ( --select items
How to select all columns from tables in join using linq Sql: select CTRL_RUN_JOB.*,
I would like to select all matches from a commaseparated column in table2, where
Example: select count(*) from my table where column1 is not null and (column1 =

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.