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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T08:29:09+00:00 2026-06-01T08:29:09+00:00

I have four different tables, one main SPECIAL table containing only id’s that reference

  • 0

I have four different tables, one main SPECIAL table containing only id’s that reference to the CONTRACT and PHONE tables.

My query looks as follows:

SELECT *
FROM `specials` specials
INNER JOIN `contract` contracts
ON  specials.contract_id = contracts.id
INNER JOIN `phone` phones
ON specials.phone_id = phones.id
INNER JOIN `ugets` ugets
ON specials.id = ugets.special_id

At the moment, this only gets ONE row from the UGETS table, but I need all rows from this specific table with the correct special_id.

Can anyone please point me in the correct direction? I can’t seem to help myself with Googling it.

  • 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-01T08:29:11+00:00Added an answer on June 1, 2026 at 8:29 am

    Your query looks about right, unless you also want all rows, regardless of the existence of a contract or phone. In this case, you’ll want to use OUTER JOIN or LEFT JOIN instead of INNER JOIN:

    SELECT *
    FROM `specials` specials
    LEFT JOIN `contract` contracts
    ON  specials.contract_id = contracts.id
    LEFT JOIN `phone` phones
    ON specials.phone_id = phones.id
    LEFT JOIN `ugets` ugets
    ON specials.id = ugets.special_id
    

    Fields from tables where there are not records for a given special will be returned with NULL, but all rows from tables where there’s a match will be shown.

    Beware this could have adverse performance impacts (possibly to the extent it voids the benefits of getting all four tables in a single query) – you should evaluate the gains vs. costs and see if you still want a single query.

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

Sidebar

Related Questions

I have a LINQ to SQL DataContext that queries four different tables. But I
I have a dilemma. Let's assume(for simplicity's sake) I have four tables, with different
I have a page that needs to combine data from four different webrequests into
I'm try to create a query which will search four different tables with one
I have a table of rows holding four different fields of numbers: people, debris,
I have four entities that I would like to translate into database tables via
I have four different lists. headers , descriptions , short_descriptions and misc . I
Hi I have a page for which I have four different style sheets like
How can I store arrays in single array? e.g. I have four different arrays,
I have a program with four different buttons. I want to interchange the position

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.