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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T18:53:55+00:00 2026-06-14T18:53:55+00:00

I have a db with 11 tables. The tables A contains 15 fields, 10

  • 0

I have a db with 11 tables.

The tables A contains 15 fields, 10 of theirs contain an id from another table or the 0 value.
Each of these tables has two fields, id and description.

I would to query the db to obtain the table A with the right description at the place of the id or null if the id is 0.

What do I have to use? join, left or inner join? how?

  • 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-14T18:53:56+00:00Added an answer on June 14, 2026 at 6:53 pm

    use this statement to select description & use left join of rest of the tables with tablea:

    IF(id = 0, NULL, description) 
    

    Example:

    SELECT A.* , IF(A.bid = 0, NULL, B.description) , IF(A.cid = 0, NULL, C.description) 
    from tablea A 
    LEFT JOIN tableb B on A.bid = B.id 
    LEFT JOIN tablec C on A.cid = C.id 
    

    and so on….

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

Sidebar

Related Questions

I have two tables with exactly the same fields. Table A contains 7160 records
I have a table Person which contains 2 fields.In my another database i have
I have a database with 3 tables. The first table contains students with fields
I have a List with some tables from a database where each row contains
I have a database table TravelRequest that contains, amongst other things, the fields SignOffName
I have a single product table with multiple fields which contain user evaluations of
I have an SQL Server 2005 table that has a varchar(250) field which contains
I have a table which contains due dates for individual member records. Each row
I have a SQL question. I have two tables: tableA and tableB. These two
I have a mysql table which has data from all flight bookings on my

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.