<?xml version="1.0" encoding="UTF-8"?>    <rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
      <channel>
        <title>Problem with Left Join</title>
        <link>https://interactivetools.com/forum/forum-posts.php?Problem-with-Left-Join-78985</link>
        <description></description>
        <pubDate>Sun, 19 Jul 2026 15:19:38 -0700</pubDate>
        <language>en-us</language>
        <atom:link href="https://interactivetools.com/forum/forum-posts.php?rss=1&amp;Problem-with-Left-Join-78985" rel="self" type="application/rss+xml" />

                <item>
          <title>Problem with Left Join</title>
          <link>https://interactivetools.com/forum/forum-posts.php?postNum=2231864#post2231864</link>
          <description><![CDATA[<p>Thank you!! :-)</p>]]></description>
          <pubDate>Fri, 20 Sep 2013 00:40:14 -0700</pubDate>
          <guid isPermaLink="true">forum-posts.php?postNum=2231864#post2231864</guid>
        </item>
                <item>
          <title>Problem with Left Join</title>
          <link>https://interactivetools.com/forum/forum-posts.php?postNum=2231863#post2231863</link>
          <description><![CDATA[
<p><code>&lt;?php $homeTeamWins = mysql_count("matches", "reti_casa &gt; reti_trasferta AND<br /> home_team = " . intval($teamRecord['num']) ) ;?&gt;</code></p>
]]></description>
          <pubDate>Thu, 19 Sep 2013 23:21:31 -0700</pubDate>
          <guid isPermaLink="true">forum-posts.php?postNum=2231863#post2231863</guid>
        </item>
                <item>
          <title>Problem with Left Join</title>
          <link>https://interactivetools.com/forum/forum-posts.php?postNum=2231862#post2231862</link>
          <description><![CDATA[
<p><code>&lt;?php $homeTeamWins = mysql_count("matches", "reti_casa &gt; reti_trasferta AND home_team = '.intval($teamRecord['num'])'");?&gt;</code></p>
<p>but there is a sintax error... <b>Parse error</b><span>: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in </span><b>/home/calciocatania/squadre/squadra.php</b><span> on line </span><b>176</b></p>]]></description>
          <pubDate>Thu, 19 Sep 2013 23:01:22 -0700</pubDate>
          <guid isPermaLink="true">forum-posts.php?postNum=2231862#post2231862</guid>
        </item>
                <item>
          <title>Problem with Left Join</title>
          <link>https://interactivetools.com/forum/forum-posts.php?postNum=2231859#post2231859</link>
          <description><![CDATA[<p>Hi,</p>

<p>Can you tell me the results you are getting?  Do you get an error message?  How are you outputting the results?</p>
<p>Thanks,</p>]]></description>
          <pubDate>Thu, 19 Sep 2013 16:11:12 -0700</pubDate>
          <guid isPermaLink="true">forum-posts.php?postNum=2231859#post2231859</guid>
        </item>
                <item>
          <title>Problem with Left Join</title>
          <link>https://interactivetools.com/forum/forum-posts.php?postNum=2231858#post2231858</link>
          <description><![CDATA[<p>Thank you for your reply Jason!</p>

<p>I have this code: </p>
<p><code>// load records<br />  list($matchesRecords, $matchesMetaData) = getRecords(array(<br />    'tableName'   =&gt; 'matches',<br /> 'where' =&gt; "home_team =".intval($squadreRecord['num']), <br />'orderBy'     =&gt; 'data_incontro ASC',<br />  ));</code></p>
<p>so how could i select only matches where  home_team num is the final num of url? i try this </p>
<p><code>&lt;?php $homeTeamWins = mysql_count("incontri", "reti_casa &gt; reti_trasferta AND squadra_casa = '.intval($squadreRecord['num'])'");?&gt; <br /><br /></code></p>
<p>but it doesn.'t work</p>]]></description>
          <pubDate>Thu, 19 Sep 2013 14:49:44 -0700</pubDate>
          <guid isPermaLink="true">forum-posts.php?postNum=2231858#post2231858</guid>
        </item>
                <item>
          <title>Problem with Left Join</title>
          <link>https://interactivetools.com/forum/forum-posts.php?postNum=2231851#post2231851</link>
          <description><![CDATA[<p>Hi,</p>
<p>Yes, the code in the example will calculate the total and store it in a variable called <span>$homeTeamWins.  You can output that value using &lt;?php echo <span>$homeTeamWins;?&gt; where ever it's needed.</span></span></p>

<p><span><span>Hope this helps</span></span></p>]]></description>
          <pubDate>Thu, 19 Sep 2013 11:12:26 -0700</pubDate>
          <guid isPermaLink="true">forum-posts.php?postNum=2231851#post2231851</guid>
        </item>
                <item>
          <title>Problem with Left Join</title>
          <link>https://interactivetools.com/forum/forum-posts.php?postNum=2231842#post2231842</link>
          <description><![CDATA[<p>hum Jason maybe you've forgotten "echo" in your code?</p>]]></description>
          <pubDate>Thu, 19 Sep 2013 02:18:00 -0700</pubDate>
          <guid isPermaLink="true">forum-posts.php?postNum=2231842#post2231842</guid>
        </item>
                <item>
          <title>Problem with Left Join</title>
          <link>https://interactivetools.com/forum/forum-posts.php?postNum=2231713#post2231713</link>
          <description><![CDATA[<p>Hi,</p>
<p>Does the code return errors?  What is the structure of the matches table?</p>

<p>Let me know and we'll see what we can work out.</p>

<p>Thanks!</p>]]></description>
          <pubDate>Fri, 06 Sep 2013 16:16:06 -0700</pubDate>
          <guid isPermaLink="true">forum-posts.php?postNum=2231713#post2231713</guid>
        </item>
                <item>
          <title>Problem with Left Join</title>
          <link>https://interactivetools.com/forum/forum-posts.php?postNum=2231712#post2231712</link>
          <description><![CDATA[<p>mmm i have this code in the list page</p>


<p><code>// load records<br /> list($teamsRecords, $teamsMetaData) = getRecords(array(<br /> 'tableName' =&gt; 'teams',<br /> 'where' =&gt; whereRecordNumberInUrl(1),<br /> 'limit' =&gt; '1',<br /> ));<br /> $teamsRecord = @$teamsRecords[0]; // get first record<br /><br /> // load records<br /> list($matchesRecords, $matchesMetaData) = getRecords(array(<br /> 'tableName' =&gt; 'matches',<br /> 'where' =&gt; "team__home =".intval($squadreRecord['num']), <br /> 'orWhere' =&gt; "team_away =".intval($squadreRecord['num']), <br /> 'orderBy' =&gt; 'date_match ASC',<br /> ));<br /><br /> // show error message if no matching record is found<br /> if (!$matchesRecord) {<br /> header("HTTP/1.0 404 Not Found");<br /> print "Record not found!";<br /> exit;<br /> }<br /><br /></code></p>

<p>so i try to put </p>
<p> &lt;?php $homeTeamWins = mysql_count("matches", "team_home_score &gt; team_away_score AND team_home = '1'");?&gt; </p>
<p>but it does'nt work... </p>]]></description>
          <pubDate>Fri, 06 Sep 2013 15:48:10 -0700</pubDate>
          <guid isPermaLink="true">forum-posts.php?postNum=2231712#post2231712</guid>
        </item>
                <item>
          <title>Problem with Left Join</title>
          <link>https://interactivetools.com/forum/forum-posts.php?postNum=2231707#post2231707</link>
          <description><![CDATA[<p>Hi Orazio,</p>

<p>You can do this using the mysql_count() function.  This function takes in a table name (ie, matches) and a where clause.  It will return a count of the records that match that where clause.</p>

<p>For example, if we assume the table is called "matches" and we have fields called team-home_score, team_away_score (both numbers) and team_home_id, we can get that count like this:</p>

<p><code>&lt;?php $homeTeamWins = mysql_count("matches", "team_home_score &gt; team_away_score AND team_home_id = 'xxx'");?&gt;</code></p>
<p>You would replace xxx with the num of the home team you were looking for.</p>

<p>Hope this helps,</p>
]]></description>
          <pubDate>Fri, 06 Sep 2013 10:51:27 -0700</pubDate>
          <guid isPermaLink="true">forum-posts.php?postNum=2231707#post2231707</guid>
        </item>
                <item>
          <title>Problem with Left Join</title>
          <link>https://interactivetools.com/forum/forum-posts.php?postNum=2231703#post2231703</link>
          <description><![CDATA[<p>Thanks greg!</p>
<p>I have another question: i would count matches in wich team_home_score &gt; team_away_score where team_home_id = xxxx</p>
<p>Is it possibile?</p>
<p>Orazio</p>]]></description>
          <pubDate>Fri, 06 Sep 2013 03:57:41 -0700</pubDate>
          <guid isPermaLink="true">forum-posts.php?postNum=2231703#post2231703</guid>
        </item>
                <item>
          <title>Problem with Left Join</title>
          <link>https://interactivetools.com/forum/forum-posts.php?postNum=2231687#post2231687</link>
          <description><![CDATA[<p>Hi,</p>
<p>I think you can solve both of these problems using the array_groupBy function. To list the logo of each home and away team I would retrieve all of the teams in a seperate variable, and then sort them by their num value using array_groupBy. Then you can easily find each teams details, something like this would work:</p>
<p><code>&lt;?php<br />    // load records from 'members'<br />  list($teams, $teamsMetaData) = getRecords(array(<br />    'tableName'   =&gt; 'teams',<br />    'loadUploads' =&gt; true,<br />    'allowSearch' =&gt; false,<br />  ));<br /><br />  //Sort the teams by there num value<br />  $teams = array_groupBy($teams, 'num', false);<br /><br />  // load records from 'members'<br />  list($matches, $matchesMetaData) = getRecords(array(<br />    'tableName'   =&gt; 'matches',<br />    'loadUploads' =&gt; true,<br />    'allowSearch' =&gt; false,<br />  ));<br /><br />  //Sort and group the matches by the round number<br />  $matches = array_groupBy($matches, 'round_num', true);<br /><br />?&gt;</code></p>
<p>then you'd use the following code to display the entries on the page:</p>
<p><code>&lt;h1&gt;Matches&lt;/h1&gt;<br />&lt;!-- matches have been grouped by round, so cycle through the rounds --&gt;<br />&lt;?php foreach($matches as $round): ?&gt;<br />  &lt;ul&gt;<br />  &lt;!-- cycle through the matches in each round --&gt;<br />  &lt;?php foreach($round as $match): ?&gt;<br />  &lt;li&gt;<br />    Result: &lt;?php echo $match['result']; ?&gt;&lt;br&gt;<br />    &lt;!-- display the match home teams title, teams have been sorted by num, so we can use the num value to find the team in the array --&gt;<br />    Home team: &lt;?php echo $teams[$match['team_home']]['title']; ?&gt;&lt;br&gt;<br />    Away team: &lt;?php echo $teams[$match['team_away']]['title']; ?&gt;<br />  &lt;/li&gt;<br />  &lt;?php endforeach; ?&gt;<br />&lt;/ul&gt;<br />&lt;?php endforeach; ?&gt;<br /><br /></code></p>
<p>This is just example code, so you'll probably need to make changes to get it working. </p>
<p>So the array_groupBy function requires the array you want to sort, the field you want to sort by, and a Boolean for if you want to group by the field or not. So I've sorted the teams by their num value, then you can use the team num value to find the correct home and away team in the array.</p>
<p>I've used the array_groupBy function on the matches as well, but grouped them by the round_num, this will create an array where all of the items with the same round_num will be grouped together, then you can cycle through each item.</p>
<p>I'd recommend using the showme function on matches and team variables so you can see the structure the array_groubBy function creates:</p>
<p><code>showme($matches); <br />echo "&lt;hr&gt;";<br />showme($teams);</code></p>
<p>Let me know if you have any questions.</p>
<p>Thanks!</p>
<p>Greg</p>
]]></description>
          <pubDate>Wed, 04 Sep 2013 09:55:06 -0700</pubDate>
          <guid isPermaLink="true">forum-posts.php?postNum=2231687#post2231687</guid>
        </item>
                <item>
          <title>Problem with Left Join</title>
          <link>https://interactivetools.com/forum/forum-posts.php?postNum=2231686#post2231686</link>
          <description><![CDATA[<p>Hum, maybe is a better solution to have two tables</p>

<p><span>Teams (num, title, logo)</span></p>
<p><span>Matches (num, round_num, team_home, team_away, result)</span></p>
<p>Team_home and team_away values are SELECT num, title  FROM `&lt;?php echo $TABLE_PREFIX ?&gt;teams`</p>

<p>My questions are:</p>
<p>Is it possibile in the list page to have one table for each round with all matches grouped by round?</p>
<p><span> Is it possibile to link team_away and team_home with cms_teams and put each teams.logo near matches.team_away and matches.team_home?</span></p>]]></description>
          <pubDate>Wed, 04 Sep 2013 01:06:39 -0700</pubDate>
          <guid isPermaLink="true">forum-posts.php?postNum=2231686#post2231686</guid>
        </item>
                <item>
          <title>Problem with Left Join</title>
          <link>https://interactivetools.com/forum/forum-posts.php?postNum=2231679#post2231679</link>
          <description><![CDATA[<p>Hi and thanks in advance for your help.</p>
<p>I'm building a soccer stats site and i have two tables</p>
<p>Teams (num, title, logo)</p>
<p>Fixtures multirecords (game, team_home1, teamaway1, result1, team_home2, team_away2, result2 and so on)</p>

<p>In the fixtures list i would have</p>
<p>GAME 1</p>
<p>TEam_home 1 - TEam_away1 - result1</p>
<p>TEam_home 2 - TEam_away2 - result2</p>
<p>etc</p>

<p>But for each team i would recall the correct logo from teams table. Is it possible with leftjoin?</p>
<p>:-)</p>]]></description>
          <pubDate>Tue, 03 Sep 2013 13:30:30 -0700</pubDate>
          <guid isPermaLink="true">forum-posts.php?postNum=2231679#post2231679</guid>
        </item>
              </channel>
    </rss>
  