<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Conditions on Count or Sum in MySQL</title>
	<atom:link href="http://codespatter.com/2008/07/22/conditions-on-count-or-sum-in-mysql/feed/" rel="self" type="application/rss+xml" />
	<link>http://codespatter.com/2008/07/22/conditions-on-count-or-sum-in-mysql/</link>
	<description></description>
	<lastBuildDate>Thu, 29 Dec 2011 08:28:29 -0600</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
	<item>
		<title>By: vai</title>
		<link>http://codespatter.com/2008/07/22/conditions-on-count-or-sum-in-mysql/comment-page-1/#comment-15227</link>
		<dc:creator>vai</dc:creator>
		<pubDate>Fri, 07 May 2010 18:47:23 +0000</pubDate>
		<guid isPermaLink="false">http://codespatter.com/?p=42#comment-15227</guid>
		<description>hai, i need help in points calculation in php.&lt;br&gt;&lt;br&gt;i did the points calculation already. but dont know to input it in the database? can anyone help me out?&lt;br&gt;&lt;br&gt;$sql =&quot;select * from tbl_predictions where user_id=&quot;.$user_id;&lt;br&gt;$result =$db-&gt;readValues($sql);&lt;br&gt;$prediction_points = 0;&lt;br&gt;&lt;br&gt;for($k=0;$kreadValues($sql);&lt;br&gt;&lt;br&gt;$week_points = 0;&lt;br&gt;if(count($predictions)&gt;0){&lt;br&gt;&lt;br&gt;for($p=0;$preadValues(&quot;select * from tbl_schedule where id_schedule=&quot;.$predictions[$p][&#039;match_id&#039;]);&lt;br&gt;$scorer_team1 = explode(&#039;^^^&#039;,$predictions[$p][&#039;scorer1&#039;]);&lt;br&gt;$scorer_team2 = explode(&#039;^^^&#039;,$predictions[$p][&#039;scorer2&#039;]);&lt;br&gt;&lt;br&gt;$sql = (&quot;select result from tbl_schedule where period=&#039;$week&#039; and id_schedule=&quot;.$predictions[$p][&#039;match_id&#039;]);&lt;br&gt;$InsertedR = $db-&gt;readValues($sql);&lt;br&gt;&lt;br&gt;$points = 0;&lt;br&gt;&lt;br&gt;if($predictions[$p][&#039;result&#039;]==$teams[0][&#039;result&#039;]){&lt;br&gt;&lt;br&gt;$points = $points+2;&lt;br&gt;&lt;br&gt;}&lt;br&gt;&lt;br&gt;if($predictions[$p][&#039;scoreline1&#039;]==$teams[0][&#039;team1_scoreline&#039;] &amp;&amp; $predictions[$p][&#039;scoreline2&#039;]==$teams[0][&#039;team2_scoreline&#039;]){&lt;br&gt;&lt;br&gt;$points = $points+2;&lt;br&gt;&lt;br&gt;}&lt;br&gt;&lt;br&gt;if($predictions[$p][&#039;goal1&#039;]==$teams[0][&#039;team1_goals&#039;] &amp;&amp; $predictions[$p][&#039;goal2&#039;]==$teams[0][&#039;team2_goals&#039;]){&lt;br&gt;&lt;br&gt;$points = $points+2;&lt;br&gt;&lt;br&gt;}&lt;br&gt;if($predictions[$p][&#039;redcard1&#039;]==$teams[0][&#039;team1_cards&#039;] &amp;&amp; $predictions[$p][&#039;redcard2&#039;]==$teams[0][&#039;team2_cards&#039;]){&lt;br&gt;&lt;br&gt;$points = $points+2;&lt;br&gt;&lt;br&gt;}&lt;br&gt;&lt;br&gt;$scorer1 = array();&lt;br&gt;$scorer2 = array();&lt;br&gt;$scorer3 = array();&lt;br&gt;$scorer4 = array();&lt;br&gt;&lt;br&gt;$scorer1 = explode(&#039;^^^&#039;,$teams[0][&#039;team1_scorer&#039;]);&lt;br&gt;$scorer2 = explode(&#039;^^^&#039;,$teams[0][&#039;team2_scorer&#039;]);&lt;br&gt;$scorer3 = explode(&#039;^^^&#039;,$predictions[$p][&#039;scorer1&#039;]);&lt;br&gt;$scorer4 = explode(&#039;^^^&#039;,$predictions[$p][&#039;scorer2&#039;]);&lt;br&gt;&lt;br&gt;$available = array_diff_assoc($scorer1, $scorer3);&lt;br&gt;&lt;br&gt;#print_r($available);&lt;br&gt;&lt;br&gt;$available1 = array_diff_assoc($scorer2, $scorer4);&lt;br&gt;&lt;br&gt;#print_r($available1);&lt;br&gt;&lt;br&gt;if(count($available)&gt;0&amp;&amp;count($available1)&gt;0){&lt;br&gt;$points = $points+2;&lt;br&gt;}&lt;br&gt;&lt;br&gt;if ($InsertedR[0][&#039;result&#039;] == 0){&lt;br&gt;&lt;br&gt;$points = 0;&lt;br&gt;}else{&lt;br&gt;$points = $points;&lt;br&gt;&lt;br&gt;}&lt;br&gt;&lt;br&gt;}&lt;br&gt;&lt;br&gt;//echo $week.&#039;===&#039;.$week_points;&lt;br&gt;$week_points = $week_points+$points;&lt;br&gt;&lt;br&gt;}&lt;br&gt;&lt;br&gt;$prediction_points =$week_points+$prediction_points ;&lt;br&gt;&lt;br&gt;// echo $total_points.&#039;=====&#039;;&lt;br&gt;&lt;br&gt;}&lt;br&gt;&lt;br&gt;?&gt;&lt;br&gt;&lt;br&gt;How input the week_points into database now, since i have created column in mysql weekPoints. the data will be insert based on user_id per user. how to do it?</description>
		<content:encoded><![CDATA[<p>hai, i need help in points calculation in php.</p>
<p>i did the points calculation already. but dont know to input it in the database? can anyone help me out?</p>
<p>$sql =&#8221;select * from tbl_predictions where user_id=&#8221;.$user_id;<br />$result =$db-&gt;readValues($sql);<br />$prediction_points = 0;</p>
<p>for($k=0;$kreadValues($sql);</p>
<p>$week_points = 0;<br />if(count($predictions)&gt;0){</p>
<p>for($p=0;$preadValues(&#8221;select * from tbl_schedule where id_schedule=&#8221;.$predictions[$p][&#39;match_id&#39;]);<br />$scorer_team1 = explode(&#39;^^^&#39;,$predictions[$p][&#39;scorer1&#39;]);<br />$scorer_team2 = explode(&#39;^^^&#39;,$predictions[$p][&#39;scorer2&#39;]);</p>
<p>$sql = (&#8221;select result from tbl_schedule where period=&#39;$week&#39; and id_schedule=&#8221;.$predictions[$p][&#39;match_id&#39;]);<br />$InsertedR = $db-&gt;readValues($sql);</p>
<p>$points = 0;</p>
<p>if($predictions[$p][&#39;result&#39;]==$teams[0][&#39;result&#39;]){</p>
<p>$points = $points+2;</p>
<p>}</p>
<p>if($predictions[$p][&#39;scoreline1&#39;]==$teams[0][&#39;team1_scoreline&#39;] &#038;&#038; $predictions[$p][&#39;scoreline2&#39;]==$teams[0][&#39;team2_scoreline&#39;]){</p>
<p>$points = $points+2;</p>
<p>}</p>
<p>if($predictions[$p][&#39;goal1&#39;]==$teams[0][&#39;team1_goals&#39;] &#038;&#038; $predictions[$p][&#39;goal2&#39;]==$teams[0][&#39;team2_goals&#39;]){</p>
<p>$points = $points+2;</p>
<p>}<br />if($predictions[$p][&#39;redcard1&#39;]==$teams[0][&#39;team1_cards&#39;] &#038;&#038; $predictions[$p][&#39;redcard2&#39;]==$teams[0][&#39;team2_cards&#39;]){</p>
<p>$points = $points+2;</p>
<p>}</p>
<p>$scorer1 = array();<br />$scorer2 = array();<br />$scorer3 = array();<br />$scorer4 = array();</p>
<p>$scorer1 = explode(&#39;^^^&#39;,$teams[0][&#39;team1_scorer&#39;]);<br />$scorer2 = explode(&#39;^^^&#39;,$teams[0][&#39;team2_scorer&#39;]);<br />$scorer3 = explode(&#39;^^^&#39;,$predictions[$p][&#39;scorer1&#39;]);<br />$scorer4 = explode(&#39;^^^&#39;,$predictions[$p][&#39;scorer2&#39;]);</p>
<p>$available = array_diff_assoc($scorer1, $scorer3);</p>
<p>#print_r($available);</p>
<p>$available1 = array_diff_assoc($scorer2, $scorer4);</p>
<p>#print_r($available1);</p>
<p>if(count($available)&gt;0&#038;&#038;count($available1)&gt;0){<br />$points = $points+2;<br />}</p>
<p>if ($InsertedR[0][&#39;result&#39;] == 0){</p>
<p>$points = 0;<br />}else{<br />$points = $points;</p>
<p>}</p>
<p>}</p>
<p>//echo $week.&#39;===&#39;.$week_points;<br />$week_points = $week_points+$points;</p>
<p>}</p>
<p>$prediction_points =$week_points+$prediction_points ;</p>
<p>// echo $total_points.&#39;=====&#39;;</p>
<p>}</p>
<p>?&gt;</p>
<p>How input the week_points into database now, since i have created column in mysql weekPoints. the data will be insert based on user_id per user. how to do it?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Greg Allard</title>
		<link>http://codespatter.com/2008/07/22/conditions-on-count-or-sum-in-mysql/comment-page-1/#comment-15194</link>
		<dc:creator>Greg Allard</dc:creator>
		<pubDate>Fri, 28 Aug 2009 20:30:02 +0000</pubDate>
		<guid isPermaLink="false">http://codespatter.com/?p=42#comment-15194</guid>
		<description>yeah that looks like it should work</description>
		<content:encoded><![CDATA[<p>yeah that looks like it should work</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: jarnail</title>
		<link>http://codespatter.com/2008/07/22/conditions-on-count-or-sum-in-mysql/comment-page-1/#comment-15193</link>
		<dc:creator>jarnail</dc:creator>
		<pubDate>Fri, 28 Aug 2009 15:27:29 +0000</pubDate>
		<guid isPermaLink="false">http://codespatter.com/?p=42#comment-15193</guid>
		<description>Hello &lt;br&gt;&lt;br&gt;I just did it.&lt;br&gt;&lt;br&gt;I used this:&lt;br&gt;  SELECT count(products_id) as count_products , SUM( reviews_rating ) as total FROM TABLE WHERE products_id=&quot;.$product_id;</description>
		<content:encoded><![CDATA[<p>Hello </p>
<p>I just did it.</p>
<p>I used this:<br />  SELECT count(products_id) as count_products , SUM( reviews_rating ) as total FROM TABLE WHERE products_id=&#8221;.$product_id;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: jarnail</title>
		<link>http://codespatter.com/2008/07/22/conditions-on-count-or-sum-in-mysql/comment-page-1/#comment-15192</link>
		<dc:creator>jarnail</dc:creator>
		<pubDate>Fri, 28 Aug 2009 15:09:42 +0000</pubDate>
		<guid isPermaLink="false">http://codespatter.com/?p=42#comment-15192</guid>
		<description>Can we do count and sum in single SQL?&lt;br&gt;&lt;br&gt;I have table where i need SUM of a field as will as I have to COUNT total rows.&lt;br&gt;&lt;br&gt;Any idea?</description>
		<content:encoded><![CDATA[<p>Can we do count and sum in single SQL?</p>
<p>I have table where i need SUM of a field as will as I have to COUNT total rows.</p>
<p>Any idea?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: buellart</title>
		<link>http://codespatter.com/2008/07/22/conditions-on-count-or-sum-in-mysql/comment-page-1/#comment-15189</link>
		<dc:creator>buellart</dc:creator>
		<pubDate>Tue, 04 Aug 2009 09:05:54 +0000</pubDate>
		<guid isPermaLink="false">http://codespatter.com/?p=42#comment-15189</guid>
		<description>ah, thanx Greg, that gave me a kick in the back!</description>
		<content:encoded><![CDATA[<p>ah, thanx Greg, that gave me a kick in the back!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: suresh vijayan</title>
		<link>http://codespatter.com/2008/07/22/conditions-on-count-or-sum-in-mysql/comment-page-1/#comment-13931</link>
		<dc:creator>suresh vijayan</dc:creator>
		<pubDate>Wed, 27 Aug 2008 11:41:37 +0000</pubDate>
		<guid isPermaLink="false">http://codespatter.com/?p=42#comment-13931</guid>
		<description>hi &lt;br&gt;myself suresh...a great programmer...if anybody needs help..just mail to me.</description>
		<content:encoded><![CDATA[<p>hi <br />myself suresh&#8230;a great programmer&#8230;if anybody needs help..just mail to me.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Luciano</title>
		<link>http://codespatter.com/2008/07/22/conditions-on-count-or-sum-in-mysql/comment-page-1/#comment-13317</link>
		<dc:creator>Luciano</dc:creator>
		<pubDate>Wed, 23 Jul 2008 01:38:23 +0000</pubDate>
		<guid isPermaLink="false">http://codespatter.com/?p=42#comment-13317</guid>
		<description>It&#039;s a good tip, thanks.</description>
		<content:encoded><![CDATA[<p>It&#39;s a good tip, thanks.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Luciano</title>
		<link>http://codespatter.com/2008/07/22/conditions-on-count-or-sum-in-mysql/comment-page-1/#comment-10942</link>
		<dc:creator>Luciano</dc:creator>
		<pubDate>Wed, 23 Jul 2008 00:38:23 +0000</pubDate>
		<guid isPermaLink="false">http://codespatter.com/?p=42#comment-10942</guid>
		<description>It&#039;s a good tip, thanks.</description>
		<content:encoded><![CDATA[<p>It&#8217;s a good tip, thanks.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: clause</title>
		<link>http://codespatter.com/2008/07/22/conditions-on-count-or-sum-in-mysql/comment-page-1/#comment-10918</link>
		<dc:creator>clause</dc:creator>
		<pubDate>Tue, 22 Jul 2008 17:17:02 +0000</pubDate>
		<guid isPermaLink="false">http://codespatter.com/?p=42#comment-10918</guid>
		<description>[...]  [...]</description>
		<content:encoded><![CDATA[<p>[...]  [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kuroki Kaze</title>
		<link>http://codespatter.com/2008/07/22/conditions-on-count-or-sum-in-mysql/comment-page-1/#comment-13316</link>
		<dc:creator>Kuroki Kaze</dc:creator>
		<pubDate>Tue, 22 Jul 2008 17:03:24 +0000</pubDate>
		<guid isPermaLink="false">http://codespatter.com/?p=42#comment-13316</guid>
		<description>Thanks, useful.</description>
		<content:encoded><![CDATA[<p>Thanks, useful.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

