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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T11:02:07+00:00 2026-06-18T11:02:07+00:00

I have 5 Tables like this: TABLE 1: PRIMARY_KEY,NAME,FK_TABLE2 TABLE 2: PRIMARY_KEY,FK_TABLE3 TABLE 3:

  • 0

I have 5 Tables like this:

  • TABLE 1: PRIMARY_KEY,NAME,FK_TABLE2
  • TABLE 2: PRIMARY_KEY,FK_TABLE3
  • TABLE 3: PRIMARY_KEY,FK_TABLE4
  • TABLE 4: PRIMARY_KEY,FK_TABLE5
  • TABLE 5: PRIMARY_KEY,DIAGRAM_NAME

And what I want is when I search for a name in a search bar, it returns Name from Table1, and also DIAGRAM_NAME from table 5.
The first part is easy:

SELECT `TABLE1`.name 
from Table 1 
Where `TABLE1`.name LIKE '%$search%'

But for the second part I need your help…
Thank you!

  • 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-18T11:02:08+00:00Added an answer on June 18, 2026 at 11:02 am

    You need to look into using JOIN:

    SELECT T.Name, T5.Diagram_Name
    FROM Table1 T
       JOIN Table2 T2 ON T.FK_TABLE2 = T2.PRIMARY_KEY
       JOIN Table3 T3 ON T2.FK_TABLE3 = T3.PRIMARY_KEY
       JOIN Table4 T4 ON T3.FK_TABLE4 = T4.PRIMARY_KEY
       JOIN Table5 T5 ON T4.FK_TABLE5 = T5.PRIMARY_KEY
    WHERE T.Name LIKE '%$search%'
    

    If you want to return the names that don’t have matching diagram names, use LEFT JOIN instead.

    Good luck.

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

Sidebar

Related Questions

I have three tables like this: Person table: person_id | name | dob --------------------------------
I have three tables like this: Table 1 structure: Name: registered_applicant_details Fields: applicant_id INT
I have 2 tables like this: Stock Table product_id bigint(20) qty float Sales Table
I have two tables which looks something like this Table Queue int ID; string
I have a couple of tables which look like this Table 1 user_id |
I have two tables associated by FK. Table student is mapped like this: @Entity
I have two tables Department and Employee . Department table looks like this: ID
I have a couple of tables with similar structures like this: <table> <tbody> <tr>content</tr>
I have two tables, like this: master --------- empcode INT PRIMARY KEY name VARCHAR
I have create two tables with reference with another table: I like this: Table1:

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.