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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T03:26:18+00:00 2026-05-31T03:26:18+00:00

I have a database and i want to extract result based on two table

  • 0

I have a database and i want to extract result based on two table of database .say tablea and tableb . php searches for particular id in tablea and if it is found it has to do the work . it may be confusing here so i will present my tabela and tableb structure here.i am showing the details for a particular user which i am filtering by where clause

tablea

id         userid
123         45
543         45
454         45
367         45
647         35
565         65


tableb

id        jid
23        123
24        123
25        123
4535      543
4536      543
4506      454
4507      454

etc

we can see that for a particular userid there may be several values in mysql tablea and for each id of tablea there may be several values in tableb id.please note that based on tablea id i want to present all data of tableb and please note that tablea id and tableb jid are same but in tableb jid will appear several times based on the number of times that occurs and for every time there will be new id in tableb. i have don e this query but it results only one output . i want to display all .

$res1 = sql_query("SELECT id from tablea  userid='{$user['id']}' order by id");

while ($row = sql_fetch_array($res1))
{
    $phid=$row['id'];
    {  
        $res2 = sql_query("select * from tableb where jid='{$phid}' order by id desc");

        $row2 = sql_fetch_array($res2);
        $d1 = $row2['id'];
        echo ' '.$d1.' ';      
    }
}​​​​​​
  • 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-31T03:26:19+00:00Added an answer on May 31, 2026 at 3:26 am

    This should make it. Although not very friendly.

    $res1 = sql_query("SELECT id from tablea  userid='{$user['id']}' order by id");
    
    while ($row = sql_fetch_array($res1)){
        $phid=$row['id'];  
        $res2 = sql_query("select * from tableb where jid='{phid}' order by id desc");
        while ($row2 = sql_fetch_array($res2)){                
            $d1 = $row2['id'];
            echo ' '.$d1.' ';      
        }
    }​​​​​​
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a database table that i want to allow my friends to update.
I have a Database table that I want to display in a DataGridView. However,
I have a database where I store two different kinds of data. One table
I have mysql database and I want a software which can draw the database
I have database application, I want to allow the user to restore the deleted
I have a MySQL database that I want to archive . What is the
I have a database field where I want to store my password. In a
I have a database schema in SQL 2005 that I want to copy to
I have a database with three tables: user_table country_table city_table I want to write
I have a database field called abCode , that I want to map to

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.