MissyMadi2
asked on
How would i write an SQL query to use Join to display CustLastName, CustFirstName and corresponding Cust_order number?
Experts,
I am trying out SQL queries and wondering how to use the join between two tables (Customers and Orders) to display last name, first name and corresponding Cust_orderNo for all records.
Table_a Customers Table_b Orders
C_ID CustLastName CustFirstName Order_ID Cust_orderNo C_ID
1 Ant Adam 1 123 1
2 Bear Brent 2 456 6
3 Cat Cathy 3 789 6
Here is what I have:
Select Customers.CustLastName, Customers.CustFirstName
FROM Customers a JOIN Orders Cust_orderNo
Also, if there were thousands of records, what is the most efficient syntax to use for this problem?
Thanks!
I am trying out SQL queries and wondering how to use the join between two tables (Customers and Orders) to display last name, first name and corresponding Cust_orderNo for all records.
Table_a Customers Table_b Orders
C_ID CustLastName CustFirstName Order_ID Cust_orderNo C_ID
1 Ant Adam 1 123 1
2 Bear Brent 2 456 6
3 Cat Cathy 3 789 6
Here is what I have:
Select Customers.CustLastName, Customers.CustFirstName
FROM Customers a JOIN Orders Cust_orderNo
Also, if there were thousands of records, what is the most efficient syntax to use for this problem?
Thanks!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
That is what I was missing - the inner join!
Thank you!
Thank you!
FROM Customers a, Orders b
where a.C_ID = b.C_ID;