How would i write an SQL query to use Join to display CustLastName, CustFirstName and corresponding Cust_order number?

MissyMadi2
MissyMadi2 used Ask the Experts™
on
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!
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Systems Development / Support Specialist
Commented:
Select    a.CustLastName,
              a.CustFirstName,
              b.Cust_orderNo  
FROM    Customers a
INNER
JOIN      Orders b
ON        a.C_ID = b.C_ID
Gerwin Jansen, EE MVETopic Advisor
Most Valuable Expert 2016

Commented:
Select a.CustLastName, a.CustFirstName, b.Cust_orderNo
FROM Customers a, Orders b
where a.C_ID = b.C_ID;

Author

Commented:
That is what I was missing - the inner join!

Thank you!

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial