Advertisement

07.25.2008 at 09:46AM PDT, ID: 23596084
[x]
Attachment Details

Simple sql join statement......

Asked by deakie in SQL Server 2005

Tags: sql, IE7

I HAVE THE FOLLOWING SELECT STATEMENTS.  WHEN I TRIED TO JOIN THEM, I DIDN'T GET THE EXPECTED RESULTS.....

SELECT TP.INVOICE, TP.FNAME, TP.LNAME, TB.INVOICE, TB.CITY, TB.STATE
     FROM dbo.NAMETABLE AS TP WITH (NOLOCK) INNER JOIN
     dbo.ADDRTABLE AS TB WITH (NOLOCK) ON TP.IDNO = TB.IDNO

SELECT PH.INVOICE, PH.PHONE    
     FROM dbo.PHONETABLE AS PH

THE RESULTS I AM GOT WERE:
INVOICE    FNAME     LNAME       PHONE      CITY      STATE
1234567       JOHN     DOE        (111)000-9999          ANYTOWN      MA
1234567       JOHN     DOE        (111)000-9999          ANYTOWN      MA
1234567       JOHN     DOE        (111)000-9999          ANYTOWN      MA

2345678       JOHN    DOE          (000)123-4567          ANYTOWN      MA
2345678       JOHN    DOE          (000)123-4567          ANYTOWN      MA
2345678       JOHN    DOE              (000)123-4567          ANYTOWN        MA

3456789       JOHN    DOE          (222)000-1111          ANYTOWN        MA
3456789       JOHN   DOE           (222)000-1111          ANYTOWN        MA
3456789       JOHN   DOE           (222)000-1111          ANYTOWN        MA

THE RESULTS I WANT ARE:
INVOICE      FNAME     LNAME       PHONE      CITY      STATE
1234567       JOHN       DOE           (111)000-9999      ANYTOWN      MA
1234567       JOHN       DOE           (000)123-4567      ANYTOWN      MA
1234567       JOHN       DOE           (222)000-1111       ANYTOWN      MA

2345678      JOHN      DOE             (111)000-9999      ANYTOWN      MA
2345678      JOHN      DOE             (000)123-4567       ANYTOWN      MA
2345678      JOHN      DOE             (222)000-1111        ANYTOWN      MA

4567890      JOHN      DOE             (111)000-9999      ANYTOWN      MA
4567890      JOHN      DOE             (000)123-4567       ANYTOWN      MA
4567890      JOHN      DOE             (222)000-1111        ANYTOWN      MA

Sorry about the all caps.....anyway, I am very much a beginner when it somes to joins, etc....How can I joins these 2 statements and get the desired result?
Start Free Trial
 
 
[+][-]07.25.2008 at 10:01AM PDT, ID: 22090347

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.25.2008 at 10:26AM PDT, ID: 22090574

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.25.2008 at 10:59AM PDT, ID: 22090850

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.25.2008 at 11:01AM PDT, ID: 22090864

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.25.2008 at 11:30AM PDT, ID: 22091123

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.25.2008 at 11:42AM PDT, ID: 22091213

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.25.2008 at 11:46AM PDT, ID: 22091237

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: SQL Server 2005
Tags: sql, IE7
Sign Up Now!
Solution Provided By: chapmandew
Participating Experts: 2
Solution Grade: A
 
 
[+][-]07.25.2008 at 12:02PM PDT, ID: 22091367

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.25.2008 at 12:09PM PDT, ID: 22091411

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.25.2008 at 12:31PM PDT, ID: 22091597

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]07.25.2008 at 12:35PM PDT, ID: 22091617

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628