slkhlaw Posted November 23, 2005 Share Posted November 23, 2005 I have the following table Table User UID FirstName LastName Table Email UID Email-ID EmailAddress Table Telephone UID Telephone ID Telephone Table Fax UID Fax-ID Fax I would like do two things 1) Output all UID, FirstName, LastName, EmailAddress, Telephone, Fax in one output. How do I do that? 2) Output UID, FirstName, LastName, EmailAddress, Telephone, Fax with given UID in one output. How do I do that? (One user may have multiple Telephone, Email address and Fax) I would appreciate if anyone could lend me a hand in this. Thank you very much indeed. Quote Link to comment Share on other sites More sharing options...
ryanlwh Posted November 23, 2005 Share Posted November 23, 2005 [!--sql--][div class=\'sqltop\']SQL[/div][div class=\'sqlmain\'][!--sql1--][span style=\'color:blue;font-weight:bold\']SELECT[/span] UID,Firstname,Lastname,EmailAddress,Telephone,Fax FROM User u LEFT JOIN Email e ON u.UID=e.UID LEFT JOIN Telephone t ON u.UID=t.UID LEFT JOIN Fax f ON u.UID=f.UID [!--sql2--][/div][!--sql3--] For the second one, add a WHERE clause [!--sql--][div class=\'sqltop\']SQL[/div][div class=\'sqlmain\'][!--sql1--][span style=\'color:blue;font-weight:bold\']SELECT[/span] UID,Firstname,Lastname,EmailAddress,Telephone,Fax FROM User u LEFT JOIN Email e ON u.UID=e.UID LEFT JOIN Telephone t ON u.UID=t.UID LEFT JOIN Fax f ON u.UID=f.UID WHERE u.UID=1 [!--sql2--][/div][!--sql3--] Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.