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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T08:08:46+00:00 2026-06-12T08:08:46+00:00

I have two tables, A and B. Fields of A: id, name —————– ID

  • 0

I have two tables, A and B.

Fields of A: id, name

-----------------
 ID |   NAME    |
-----------------
 1  |   name1   |
-----------------
 2  |   name2   |
-----------------
 3  |   name3   |
-----------------
 4  |   name4   |
-----------------
 5  |   name5   |
-----------------

Fields of B: bid, id

-----------------
 BID    |   ID  |
-----------------
 11     |   1   |
-----------------
 11     |   2   |
-----------------
 12     |   1   |
-----------------
 12     |   2   |
-----------------
 12     |   3   |
-----------------

I want to perform a query to show ALL records from A with columns A.id, A.name on the left. And join a third column from B ON id WHERE bid = ’11’.

So I would have something like this:

--------------------------------
 A.ID   |   A.NAME  |   B.BID
--------------------------------
 1      |   name1   |   11
--------------------------------
 2      |   name2   |   11
--------------------------------
 3      |   name3   |
--------------------------------
 4      |   name4   |
--------------------------------
 5      |   name5   |
--------------------------------

Any suggestions?

  • 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-12T08:08:47+00:00Added an answer on June 12, 2026 at 8:08 am

    You will want to use a LEFT JOIN

    SELECT A.ID, A.NAME, B.BID
    FROM A
    LEFT JOIN B
       ON A.id = B.id
    WHERE B.BID = yourValue -- use the WHERE clause for additional filtering
    

    See SQL Fiddle With Demo

    Based on your update, you will want to move the filter from the WHERE clause to the JOIN:

    SELECT A.ID, A.NAME, IFNULL(B.BID, '') BID
    FROM A
    LEFT JOIN B
       ON A.id = B.id
      and b.bid = 11
    

    See SQL Fiddle with Demo

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

Sidebar

Related Questions

Say I have two tables called A (fields: id, phase, name) and B(fields: id,
I have two tables: Folder, Files. Each table has 4 fields: ParentID, ID, Name,
I have two tables that look as Follows: Person (Table Name) Name1/Phone1/Email1/Address1/Organization1/Notes1 (Fields) Organization
In SQL server 2008: Suppose I have two tables. Table1 has 3 fields: Name,
I have two tables: countries with fields [objid(PK), name] cities with fields [objid(PK), name,
I have two tables like this. Table 1 Fields: CId , Name Table 2
I have two tables that have the exact same fields and I want to
i have two tables table1 fields fid,fname,fage a ,abc ,20 b ,bcv ,21 c
I have two tables with exactly the same fields. Table A contains 7160 records
I have two tables in a SQLite DB, and both have the following fields:

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.