Link to home
Start Free TrialLog in
Avatar of MissyMadi2
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!
ASKER CERTIFIED SOLUTION
Avatar of Anuradha Goli
Anuradha Goli
Flag of Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Gerwin Jansen
Select a.CustLastName, a.CustFirstName, b.Cust_orderNo
FROM Customers a, Orders b
where a.C_ID = b.C_ID;
Avatar of MissyMadi2
MissyMadi2

ASKER

That is what I was missing - the inner join!

Thank you!