Note that there are some explanatory texts on larger screens.

plurals
  1. PONeed assistance Joining Two Tables
    primarykey
    data
    text
    <p>i have been unable to understand how to join 2 tables together so i may grab info from one and sort by another. It actually looks like the first table actually creates a "row" variable to use later. I tried asking before but it didn't help so im going to try and explain better and maybe il learn something... Im hoping someone here will be able to help me make a working code that will do this for me. My current line of code i am using is</p> <pre><code>$sql3 = new db; $sql3-&gt;db_Select(DB_TABLE_ROSTER_TEAM_MEMBERS, "*", "team_id = ".intval($row1['team_id'])." ORDER BY member_team_order"); </code></pre> <p>However i need it to order by a diff field on another table. on the other table it would look like this</p> <pre><code>$sql3 = new db; $sql3-&gt;db_Select(DB_TABLE_ROSTER_MEMBERS, "*", ORDER BY member_status"); </code></pre> <p>Please note that all i need the other table for is to order by the member_status. </p> <p>Im guessing this is possible but the join command seems very complicated and i cant wrap my head around it alone. so im looking for help from the experts(you). Im doing my best to explain but If there is any info i can give to help please let me know. </p> <p>This code im trying to modify is way above me but i do like a challenge...</p> <h2>Table Structures-</h2> <p><strong>Table Name-</strong> roster_team_members<br> <strong>Fields-</strong> member_id, member_name, team_id, team_name, game_id, game_name, member_team_status, text_color, member_team_order</p> <p><strong>Table Name-</strong> roster_members<br> <strong>Fields-</strong> member_id, nickname, real_name, external_image, active_external_image, member_status,leader_status,leader_order, member_application_date</p> <p>UPDATE-</p> <pre><code>$sql3 = new db; $sql3 ="select t.* from #roster_team_members as t "; $sql3 .="inner join #roster_members on t.member_id =m.member_id "; $sql3 .="where t.team_id=".intval($row1['team_id']); $sql3 .="order by m.member_status"; $db-&gt;db_select_gen($sql3); while($row3 = $db-&gt;db_Fetch()) { </code></pre> <p>and im getting a Fatal Error- Fatal error: Call to a member function db_select_gen() on a non-object in D:\wamp\www\DTK_Testing_Site\e107_plugins\jbroster_menu\jbroster.php on line 523</p> <p>line 523 is the $db->db_select_gen($sql3); line. any ideas?</p> <p>UPDATE2- replaced the above with this-</p> <pre><code>$sql3 = new db; $sql3 -&gt; db_Select_gen("select t.* from ".e107_jbclan_roster_team_members." as t inner join ".e107_jbclan_roster_members." on t.member_id =m.member_id WHERE t.team_id=@team_id ORDER BY m.member_status") or die(mysql_error()); </code></pre> <p>and now im just getting these small errors like... Unknown column 'm.member_id' in 'on clause' im so close to finishing this. any more help would be awesome...</p> <pre><code>while($row3 = $db-&gt;db_Fetch()) { </code></pre> <p><strong>IV DONE IT!!!!</strong> I couldnt have done it without you Guilhem Hoffmann. Thank you so much... Finally this issue is resolved and i can live my life again lol. thx stackoverflow.com!!!!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload