 




<?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: Update a subquery with different tables</title>
	<atom:link href="http://itknowledgeexchange.techtarget.com/itanswers/update-a-subquery-with-different-tables/feed/" rel="self" type="application/rss+xml" />
	<link>http://itknowledgeexchange.techtarget.com/itanswers/update-a-subquery-with-different-tables/</link>
	<description></description>
	<lastBuildDate>Thu, 23 May 2013 19:49:48 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
	<item>
		<title>By: carlosdl</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/update-a-subquery-with-different-tables/#comment-88362</link>
		<dc:creator>carlosdl</dc:creator>
		<pubDate>Fri, 18 Feb 2011 23:19:42 +0000</pubDate>
		<guid isPermaLink="false">#comment-88362</guid>
		<description><![CDATA[Great.

You are welcome.

Different options could produce different response times.  If this is going to be run regularly, it would be a good idea to look for the most efficient alternative.]]></description>
		<content:encoded><![CDATA[<p>Great.</p>
<p>You are welcome.</p>
<p>Different options could produce different response times.  If this is going to be run regularly, it would be a good idea to look for the most efficient alternative.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: bartbart</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/update-a-subquery-with-different-tables/#comment-88359</link>
		<dc:creator>bartbart</dc:creator>
		<pubDate>Fri, 18 Feb 2011 21:56:33 +0000</pubDate>
		<guid isPermaLink="false">#comment-88359</guid>
		<description><![CDATA[Carlos,
After trying the First option,,, It worked. Thanks for your help.
I thought I&#039;d have to connect the items prior to the sub query but i did not.

Thanks again.]]></description>
		<content:encoded><![CDATA[<p>Carlos,<br />
After trying the First option,,, It worked. Thanks for your help.<br />
I thought I&#8217;d have to connect the items prior to the sub query but i did not.</p>
<p>Thanks again.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: bartbart</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/update-a-subquery-with-different-tables/#comment-88355</link>
		<dc:creator>bartbart</dc:creator>
		<pubDate>Fri, 18 Feb 2011 21:07:07 +0000</pubDate>
		<guid isPermaLink="false">#comment-88355</guid>
		<description><![CDATA[Carlos, 
I have not had a chance to try but the goal is to pull history information on parts (MMITNO or MHITNO)  and if no usage in the past 2 years (or some time frame) then change the status (MMSTST) to 01.
We are on MS SQL 2005]]></description>
		<content:encoded><![CDATA[<p>Carlos,<br />
I have not had a chance to try but the goal is to pull history information on parts (MMITNO or MHITNO)  and if no usage in the past 2 years (or some time frame) then change the status (MMSTST) to 01.<br />
We are on MS SQL 2005</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: carlosdl</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/update-a-subquery-with-different-tables/#comment-88278</link>
		<dc:creator>carlosdl</dc:creator>
		<pubDate>Thu, 17 Feb 2011 21:15:55 +0000</pubDate>
		<guid isPermaLink="false">#comment-88278</guid>
		<description><![CDATA[Also, could you please explain what you are trying to accomplish (with words) ?

&lt;b&gt;Maybe &lt;/b&gt;something like this is what you are looking for:

&lt;pre&gt;update MVXJDTA.MITMAS 
set MMSTAT =&#039;01&#039; 
where MVXJDTA.MITMAS.MMITNO IN
(Select MHITNO
from MVXJDTA.MITSTA 
where MHCYP6 Between 200801 and 201102 
Group by MHITNO 
Having SUM(MHMAQT+MHPUQT + MHSOQT + MHUSQT + MHDEMQ) &lt;= 0)&lt;/pre&gt;

Or this (this syntax may not work in all databases):

&lt;pre&gt;update MVXJDTA.MITMAS m
set MMSTAT =&#039;01&#039; 
where EXISTS 
(Select 1
from MVXJDTA.MITSTA 
where MHCYP6 Between 200801 and 201102
AND MHITNO = m.MMITNO
Group by MHITNO 
Having SUM(MHMAQT+MHPUQT + MHSOQT + MHUSQT + MHDEMQ) &lt;= 0)&lt;/pre&gt;]]></description>
		<content:encoded><![CDATA[<p>Also, could you please explain what you are trying to accomplish (with words) ?</p>
<p><b>Maybe </b>something like this is what you are looking for:</p>
<pre>update MVXJDTA.MITMAS 
set MMSTAT ='01' 
where MVXJDTA.MITMAS.MMITNO IN
(Select MHITNO
from MVXJDTA.MITSTA 
where MHCYP6 Between 200801 and 201102 
Group by MHITNO 
Having SUM(MHMAQT+MHPUQT + MHSOQT + MHUSQT + MHDEMQ) &lt;= 0)</pre>
<p>Or this (this syntax may not work in all databases):</p>
<pre>update MVXJDTA.MITMAS m
set MMSTAT ='01' 
where EXISTS 
(Select 1
from MVXJDTA.MITSTA 
where MHCYP6 Between 200801 and 201102
AND MHITNO = m.MMITNO
Group by MHITNO 
Having SUM(MHMAQT+MHPUQT + MHSOQT + MHUSQT + MHDEMQ) &lt;= 0)</pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: carlosdl</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/update-a-subquery-with-different-tables/#comment-88277</link>
		<dc:creator>carlosdl</dc:creator>
		<pubDate>Thu, 17 Feb 2011 20:58:28 +0000</pubDate>
		<guid isPermaLink="false">#comment-88277</guid>
		<description><![CDATA[What database product are you using ?]]></description>
		<content:encoded><![CDATA[<p>What database product are you using ?</p>
]]></content:encoded>
	</item>
</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Page Caching using memcached
Database Caching 6/9 queries in 0.013 seconds using memcached
Object Caching 324/327 objects using memcached

Served from: itknowledgeexchange.techtarget.com @ 2013-05-23 20:08:54 -->