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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T23:41:05+00:00 2026-06-17T23:41:05+00:00

How to join two tables and get specific records only? I have two tables

  • 0

How to join two tables and get specific records only?

I have two tables

  1. Supplier — Columns (supp_id,supp_code,supp_name,address)
  2. SelectedSuppliers — columns (supplier_id,is_selected, date_a)

I load the all the suppliers to grid view and select specific suppliers by check box

For specific date from supplier table then it goes to SelectedSupplier table .

When I load saved suppliers from SelectedSupplier table I need to view all the suppliers from two tables. Which means if I added a new supplier it should be display when I’m loading second time .

This is my query

SELECT
    `supplier`.`supp_id`,
    `supplier`.`supp_name`,
    `supplier`.`address`,
    `supplier`.`supp_code`,
    `SelectedSuppliers `.`is_selected`
FROM 
    `SelectedSuppliers `
LEFT JOIN 
    `supplier` ON (`shop_list`.`supplier_id` = `supplier`.`supp_id`)
WHERE
    SelectedSuppliers.date_a = '2013-1-5'

It works but load SelectedSupplier records only not all records

Thanks.

  • 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-17T23:41:06+00:00Added an answer on June 17, 2026 at 11:41 pm

    It’s not at all clear why you have a reference to shop_list, when that table or alias doesn’t appear in your query, or why one of your table names includes a trailing space,

    From your description, I think you want supplier to be on the left side of the LEFT JOIN (to return all rows from the supplier table.

    (I replaced the reference to shop_list with a reference to the SelectedSuppliers. I left the trailing space on the table name, as in your example query.)

    SELECT s.supp_id
         , s.supp_name
         , s.address
         , s.supp_code
         , e.is_selected
      FROM `supplier` s
      LEFT 
      JOIN `SelectedSuppliers ` e
        ON e.supplier_id = s.supp_id
       AND e.date_a = '2013-1-5'
    

    All rows will be returned from the table on the left side (in this query, that’s supplier), along with any matching rows from the table on the right side.

    The value for is_selected in will be NULL when there is no matching row in the SelectedSuppliers table. This can easily be replaced with a 0, if that’s desired, by wrapping that in an IFNULL function.

    If your intent is to EXCLUDE suppliers that are already selected, we can add a simple predicate to the query to eliminate the matching rows:

    WHERE e.supplier_id IS NULL 
    

    That will return rows from supplier where there is no matching row in the SelectedSuppliers table,

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

Sidebar

Related Questions

I want to join two tables (below) which i get. But then I want
I'm trying to LEFT JOIN two tables, to get a list of all rows
Actually if i am doing INNER JOIN of two tables then i will get
I want to join two tables with several hundred columns, like this: select *
Is is possible to programatically join two tables using Django's ORM? I have two
I have been trying to join two tables (USERS AND USERS_ROLES) based on their
I want to get the results of a left join between two tables, with
I need to Join two tables where each row in the first table get
I'm trying to JOIN two tables but it isn't working properly. I have loc_id
I want to join two tables using JPQL : SELECT * FROM A LEFT

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.