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. Link to comment https://forums.phpfreaks.com/topic/2924-select-question/ 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--] Link to comment https://forums.phpfreaks.com/topic/2924-select-question/#findComment-9811 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.