unemployment Posted April 2, 2011 Share Posted April 2, 2011 I have a ridiculously long query that I have created to combine three tables. I want to combine my third table into the preexisting inner joined tables. Ideally, the output I am looking for is that when I add the third join, I need it to not combine the rows, but rather just add in rows and order the data by datetime. How do I make it so that the data is combined, but the rows aren't smooshed together. Do I need to use an outer join. Let me know if you need a more concrete example. Quote Link to comment https://forums.phpfreaks.com/topic/232470-three-mysql-joins-what-join-to-use/ Share on other sites More sharing options...
requinix Posted April 2, 2011 Share Posted April 2, 2011 Like... append the rows from the third table into the results from the query? Yes, a concrete example would be nice. Quote Link to comment https://forums.phpfreaks.com/topic/232470-three-mysql-joins-what-join-to-use/#findComment-1195792 Share on other sites More sharing options...
unemployment Posted April 2, 2011 Author Share Posted April 2, 2011 table 1 has firstname user_id table 2 has company_id user_id fan_date Current results generated with firstname user_id fan_date person1 3 2011-04-02 00:00:00 person2 1 2011-04-06 15:35:42 person2 1 2011-04-06 15:35:42 person2 1 2011-04-06 15:35:42 person2 1 2011-04-06 15:35:42 From: SELECT `users`.`firstname`, `company_fans`.`user_id`, `company_fans`.`fan_date` FROM `partners` LEFT JOIN `users` ON `partners`.`user_id` = `users`.`id` LEFT JOIN `company_fans` ON `partners`.`user_id` = `company_fans`.`user_id` But the users table doesn't have a fan_date and the fan_date doesn't go with the users table. I just want the table listing to be like... person1 3 null person2 1 null person2 1 null person2 1 null person2 1 null person1 3 2011-04-02 00:00:00 person2 1 2011-04-06 15:35:42 Quote Link to comment https://forums.phpfreaks.com/topic/232470-three-mysql-joins-what-join-to-use/#findComment-1195794 Share on other sites More sharing options...
fenway Posted April 3, 2011 Share Posted April 3, 2011 Sorry, I don't follow. Quote Link to comment https://forums.phpfreaks.com/topic/232470-three-mysql-joins-what-join-to-use/#findComment-1196249 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.