How to select data from 2 different tables
Tables : CustomerTBL , OrdersTBL
CustomerTBL
custID custName
1 Tom
2 Laura
OrdersTBL
orderID custID OrderTotal
300 1 10
301 2 20
302 1 5
Requirement
Customer Name, orderID and OrderTotal for Tom with 1 SQL queery
SQL Query
SELECT a.custName , b.orderID , b.OrderTotal
FROM CustomerTBL as a INNER JOIN OrdersTBL as b ON a.custID = b.custID
WHERE a.custName = ‘Tom’
Result
custName orderID OrderTotal
Tom 300 10
Tom 302 5

