<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Think Lamp &#187; sybase</title>
	<atom:link href="http://www.think-lamp.com/tag/sybase/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.think-lamp.com</link>
	<description>Everything Linux Apache Php Mysql</description>
	<lastBuildDate>Sun, 05 Sep 2010 00:50:34 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Multiple SQL Queries in a Stored Procedure.</title>
		<link>http://www.think-lamp.com/2008/12/multiple-sql-queries-in-a-stored-procedure/</link>
		<comments>http://www.think-lamp.com/2008/12/multiple-sql-queries-in-a-stored-procedure/#comments</comments>
		<pubDate>Thu, 18 Dec 2008 21:21:40 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[sql]]></category>
		<category><![CDATA[stored procedure]]></category>
		<category><![CDATA[sybase]]></category>

		<guid isPermaLink="false">http://www.think-lamp.com/?p=121</guid>
		<description><![CDATA[Working on a Thursday afternoon, I came across a problem where we had to return multiple counts (about 10 of them ) in an application. One way was to have multiple stored procedures and call them one by one, but this would mean I would have to make 10 connections to the database and 10 [...]]]></description>
			<content:encoded><![CDATA[<div class="Q2bXSc">Working on a Thursday afternoon, I came across a problem where we had to <strong>return multiple counts</strong> (about 10 of them ) in an application. One way was to have multiple stored procedures and call them one by one, but this would mean I would have to make 10 connections to the database and 10 opens , 10 closes, phew !</div>
<p><script type="text/javascript"><!--
google_ad_client = "pub-3741710014597097";
/* 468x15, created 3/25/09 */
google_ad_slot = "1110499399";
google_ad_width = 468;
google_ad_height = 15;
//-->
</script><br />
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>
<div class="Q2bXSc">So I decided to combine all of them into one:</div>
<div class="Q2bXSc"><span id="more-121"></span></div>
<div class="RNCQof">
<div class="Q2bXSc"><strong><span id=":1rj"></p>
<pre class="brush: sql;">
SELECT &quot;totaltrees&quot; =(SELECT count(*)  FROM Forest f  WHERE f.trees= @forestId),
&quot;totalplants&quot; =(SELECT count(*)  FROM Forest f WHERE f.plants= @forestId),
&quot;totalUsers&quot;=(SELECT count(*)  FROM Users u WHERE u.groupId= @groupId)
</pre>
<p></span></strong></div>
</div>
<div class="Q2bXSc">Here you can add as many as queries you want and from different tables, counts, columns etc. Just one thing, The result of each query should have a unique value, thus you can&#8217;t do select *  !!</div>
<div class="Q2bXSc">Or something like: select country_name FROM world.</div>
<div class="Q2bXSc">cool ! isn&#8217;t it ?</div>
<a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Fwww.think-lamp.com%2F2008%2F12%2Fmultiple-sql-queries-in-a-stored-procedure%2F&amp;linkname=Multiple%20SQL%20Queries%20in%20a%20Stored%20Procedure."><img src="http://www.think-lamp.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a>]]></content:encoded>
			<wfw:commentRss>http://www.think-lamp.com/2008/12/multiple-sql-queries-in-a-stored-procedure/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
	</channel>
</rss>
