Table join and display issue - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Table join and display issue (/showthread.php?tid=42565) |
Table join and display issue - El Forum - 06-10-2011 [eluser]debow[/eluser] I'm trying to display similar info from 3 tables into one. It's somewhat working but is only showing the last joined table not all 3. I'm not sure what is wrong at this point. Any suggestions are welcomed. controller.php Code: function getevents() { model.php Code: function getevents() { view.php Code: <h4>Score Sheet</h4> Current results Code: SELECT * FROM (`100m_times`) JOIN `400m_times` ON `400m_times`.`name` = `100m_times`.`name` JOIN `mile_times` ON `mile_times`.`name` = `100m_times`.`name` LEFT JOIN `swim_times` ON `swim_times`.`name` = `100m_times`.`name` This is what I get outputed. Score Sheet ID Name Event 238 Dan Dudley 100m Swim 239 Tom Clancey 100m Swim 237 Mike Jones 100m Swim What I want is this Score Sheet ID Name Event 238 Dan Dudley 100m Swim 239 Tom Clancey 100m Swim 237 Mike Jones 100m Swim 238 Dan Dudley 100m 239 Tom Clancey 100m 237 Mike Jones 100m 238 Dan Dudley 400m 239 Tom Clancey 400m 237 Mike Jones 400m Table join and display issue - El Forum - 06-10-2011 [eluser]CroNiX[/eluser] You might need to make all of your joins left joins there. Table join and display issue - El Forum - 06-13-2011 [eluser]debow[/eluser] I was able to get what I wanted by using UNION instead of JOIN. Table join and display issue - El Forum - 06-13-2011 [eluser]danmontgomery[/eluser] You probably have identical column names in all of the tables, in which case they are all overwritten with the last table joined, since php can't have an array/object with identical keys. |