+ 1

I don't understand about joining table. Can anyone help me Please?

SELECT customers.ID, customers.Name, orders.Name, orders.Amount FROM customers, orders WHERE customers.ID=orders.Customer_ID ORDER BY customers.ID;

2nd Sep 2018, 2:44 PM
Mahmudur Rahman
Mahmudur Rahman - avatar
1 Answer
+ 1
You combine the tables customers and orders to get data from both tables. In your example, you select id and name from the customers table and name and amount from the orders table. The orders table has a value Customer_ID which is a foreign key to the customers table. If it matches the value ID from the customers table, you know that the customer with that ID is the one who bought the item from the orders table. That's what you check with the WHERE statement.
2nd Sep 2018, 2:58 PM
Anna
Anna - avatar