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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T01:58:09+00:00 2026-06-14T01:58:09+00:00

I have 2 tables. TABLE_1 category_id name parent_id 1 test 0 2 test1 1

  • 0

I have 2 tables.

TABLE_1

category_id   name   parent_id
1             test    0
2             test1   1 
3             test2   1  
4             test3   1
5             test4   2
.

TABLE_2

pro_id   category_id   name
1        2            prod1
2        2            prod2
3        3            prod3
4        5            prod4
.
. 
.

I need to do this

  1. get all category_ids where parent_id = given... (say ‘1’)
  2. query in another table with where in (all the ids returned from 1) )… should be where in ('2,3,4') in the example case

OUTPUT

all fields of pro_id (1,2,3 in this case) from TABLE 2..

tried this.. (hoping this will work 🙂 )

select * from TABLE_2 
where category_id in (select category_id from TABLE_1 where parent_id = 1) 

but no result.

I could have done all this in PHP script. But had a problem with pagination. So I want to make it work in one query.

So is it possible to do this? Get the result from a query and use it in other in a single query? If so then I would appreciate your help.

  • 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-14T01:58:10+00:00Added an answer on June 14, 2026 at 1:58 am

    this is weird .. but the query i provided was working…. 🙂 🙂

    select * from TABLE_2 where category_id in (select category_id from TABLE_1 where parent_id = 1) 
    

    anywasy thanks guys…

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

Sidebar

Related Questions

I have the following MySql Table: -------------------------------------------- Table 'category' -------------------------------------------- category_id name parent_id 1
Say we have this tables t1 -------------------------------- category_id | name | lft | rgt
I have two tables: parent-child 'categories': id name parent_id 1 Food NULL 2 Pizza
I have two tables 1: itemInfo product_id brand name category 1 Garden Goodcake cake
I have two Tables: Table 1: Questions : QuestionId NUMERIC Title TEXT Test Data
I have 5 tables: library_item ============ id title description index_text library_item_rel_category ========================= item_id category_id
I have table as +-------------+----------------------+--------------------+ | category_id | name | parent_category_id | +-------------+----------------------+--------------------+ |
I have Two tables like this: Table categories: columns: id, name, parent 1, Foods,
I have two tables: Product ------------------------------------ id group_id name quick_select ------------------------------------ 1 1 product1
I have a table that looks like this: category category_id name category_seo_friendly_url left_id right_id

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.