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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T21:07:16+00:00 2026-06-17T21:07:16+00:00

I have 2 tables table Customer cus_id cus_name table Buying buy_id, cus_id(FK to Customer),

  • 0

I have 2 tables

table Customer

  • cus_id
  • cus_name

table Buying

  • buy_id,
  • cus_id(FK to Customer),
  • price

The result that I want

cus_id, cus_name, buy_id, price

but in case some customers don’t have buy_id. How can I query like this.

cus_id, cus_name, null, null
  • 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-17T21:07:18+00:00Added an answer on June 17, 2026 at 9:07 pm

    use LEFT JOIN if you want to display all customer even if he hasn’t buy anything yet.

    SELECT  a.*, b.buy_id, b.price
    FROM    customer a
            LEFT JOIN buying b
                ON a.cus_id = b.cus_id
    

    To fully gain knowledge about joins, kindly visit the link below:

    • Visual Representation of SQL Joins
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i hava a set of following tables customer(cus_id,cus_name); jointAccount(cus_id,acc_number,relationship); account(acc_number,cus_id) now i want to
I have a set of tables as following: customer( cus_id ,cus_name) account( acc_num ,acc_balance,
I have two tables in my database that look like that: Customer: C_ID city
I have this following problem: I have two tables 1 table for customer bought
I have 3 tables: Customer, CustomerTypes, CustomerCustomerTypes. CustomerCustomerTypes is basically is a bridge table
I have two tables as follows: CREATE TABLE customer ( id INT NOT NULL
I have 3 tables. cinema, booking and customer create table cinema ( c_id int,
Lets say i have four tables i want to read from: customer customer_id, customer_name
I am trying to query top 3 customers. I have 3 tables: Customer table
I have two tables. customer table It has 3 fields.. customer_id first_name last_name customer

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.