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

  • Home
  • SEARCH
  • 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 6363953
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T00:06:09+00:00 2026-05-25T00:06:09+00:00

I have a situation where a property table holds an address id (from the

  • 0

I have a situation where a property table holds an address id (from the g_addresses table) and an applicant table also holds an address id from the g_addresses.
I’d like to left join these together but select all the fields in the table.

I know of using ‘as’ to make an alias for fields, but is there any way to produce an alias for a whole table?

SELECT *
FROM (`reference`)
LEFT JOIN `applicants` ON `applicants`.`id` = `reference`.`applicant_id`
LEFT JOIN `g_people` applicant_person ON `applicant_person`.`id` = `applicants`.`person_id`
LEFT JOIN `g_addresses` applicant_address ON `applicant_address`.`id` = `applicants`.`address_id`
LEFT JOIN `properties` ON `properties`.`id` = `reference`.`property_id`
LEFT JOIN `g_addresses` property_address ON `property_address`.`id` = `properties`.`address_id`
WHERE `reference`.`id` = 4 

This produces a result containing only one address row and not both,
The row that is returned is the row from the final join and not the one previously, indicating it is overwriting when it is returned.

  • 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-25T00:06:10+00:00Added an answer on May 25, 2026 at 12:06 am

    I don’t think you should use masked references, like * or `reference`.*, in your case, because you may end up with a row set containing identical column names (id, address_id).

    If you want to pull all the columns from the joined tables, you should probably specify them individually in the SELECT clause and assign a unique alias to every one of them:

    SELECT
      ref.`id` AS ref_id,
      ref.`…`  AS …,
      …
      app.`id` AS app_id,
      …
    FROM `reference` AS ref
    LEFT JOIN `applicants`  AS app ON app.`id` = ref.`applicant_id`
    LEFT JOIN `g_people`    AS ape ON ape.`id` = app.`person_id`
    LEFT JOIN `g_addresses` AS apa ON apa.`id` = app.`address_id`
    LEFT JOIN `properties`  AS pro ON pro.`id` = ref.`property_id`
    LEFT JOIN `g_addresses` AS pra ON pra.`id` = pro.`address_id`
    WHERE ref.`id` = 4
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have situation like this: class IData { virtual void get() = 0; virtual
I have situation in which I read a record from a database. And if
I have situation like this: user submits form with action='/pay' in '/pay' I have
I have a situation where I have 4-5 very similar classes which I'd like
I have a situation where I need to take a quantity consumed from one
i have a table called propAmenities which holds two column amenity_id and property_id basically
The situation is as follows: I have a ViewModel that has a property that's
I have a table, in that table I have users something like this: id
Here is my situation. I have a table with below data. Property_name Property_value --------------------------------------
I'm pretty new to Hibernate. In my situation I have a concrete table with

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.