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
use
LEFT JOINif you want to display all customer even if he hasn’t buy anything yet.To fully gain knowledge about joins, kindly visit the link below: