<?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: How to select from an update target in MySQL</title>
	<atom:link href="http://www.xaprb.com/blog/2006/06/23/how-to-select-from-an-update-target-in-mysql/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.xaprb.com/blog/2006/06/23/how-to-select-from-an-update-target-in-mysql/</link>
	<description>Stay curious!</description>
	<lastBuildDate>Thu, 09 Feb 2012 09:56:43 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
	<item>
		<title>By: Sam</title>
		<link>http://www.xaprb.com/blog/2006/06/23/how-to-select-from-an-update-target-in-mysql/#comment-19686</link>
		<dc:creator>Sam</dc:creator>
		<pubDate>Tue, 11 Oct 2011 13:30:53 +0000</pubDate>
		<guid isPermaLink="false">http://www.xaprb.com/blog/?p=174#comment-19686</guid>
		<description>Thanks mate, worked just fine</description>
		<content:encoded><![CDATA[<p>Thanks mate, worked just fine</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Craig</title>
		<link>http://www.xaprb.com/blog/2006/06/23/how-to-select-from-an-update-target-in-mysql/#comment-19660</link>
		<dc:creator>Craig</dc:creator>
		<pubDate>Wed, 28 Sep 2011 05:12:09 +0000</pubDate>
		<guid isPermaLink="false">http://www.xaprb.com/blog/?p=174#comment-19660</guid>
		<description>You need to make the inner select a temporary table (just wrap the select in another select).

Here is a good example.

http://www.toofishes.net/blog/agony-simple-things-mysql/

Annoying and painful, but that&#039;s mysql..

Postgres would run the same sql as oracle with no problems, it&#039;s a much better enterprise DB in my opinion.</description>
		<content:encoded><![CDATA[<p>You need to make the inner select a temporary table (just wrap the select in another select).</p>
<p>Here is a good example.</p>
<p><a href="http://www.toofishes.net/blog/agony-simple-things-mysql/" rel="nofollow">http://www.toofishes.net/blog/agony-simple-things-mysql/</a></p>
<p>Annoying and painful, but that&#8217;s mysql..</p>
<p>Postgres would run the same sql as oracle with no problems, it&#8217;s a much better enterprise DB in my opinion.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Maglebolia</title>
		<link>http://www.xaprb.com/blog/2006/06/23/how-to-select-from-an-update-target-in-mysql/#comment-19659</link>
		<dc:creator>Maglebolia</dc:creator>
		<pubDate>Tue, 27 Sep 2011 14:26:23 +0000</pubDate>
		<guid isPermaLink="false">http://www.xaprb.com/blog/?p=174#comment-19659</guid>
		<description>Hello there, I&#039;ve created my command for oracle and now I need it for mysql. Actually I have no clue of how to do this with one update command (will be a trigger afterwords). Here is my oracle command. I would appreciate if anyone can convert this to mysql.

UPDATE animal_table
     SET (animal_info1, 
          animal_info2, 
          animal_info3) = (SELECT animal_nbr, animal_amount, &#039;00&#039;
                           FROM animal_table t2
                           WHERE t2.category_id = animal_table.category_id
                             AND t2.sumary_id = animal_table.summary_id
                             AND t2.animal_type = &#039;special&#039;
                          )
  WHERE animal_type = &#039;cats&#039;
    AND category_id = &#039;foo&#039;</description>
		<content:encoded><![CDATA[<p>Hello there, I&#8217;ve created my command for oracle and now I need it for mysql. Actually I have no clue of how to do this with one update command (will be a trigger afterwords). Here is my oracle command. I would appreciate if anyone can convert this to mysql.</p>
<p>UPDATE animal_table<br />
     SET (animal_info1,<br />
          animal_info2,<br />
          animal_info3) = (SELECT animal_nbr, animal_amount, &#8217;00&#8242;<br />
                           FROM animal_table t2<br />
                           WHERE t2.category_id = animal_table.category_id<br />
                             AND t2.sumary_id = animal_table.summary_id<br />
                             AND t2.animal_type = &#8216;special&#8217;<br />
                          )<br />
  WHERE animal_type = &#8216;cats&#8217;<br />
    AND category_id = &#8216;foo&#8217;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: javaspc</title>
		<link>http://www.xaprb.com/blog/2006/06/23/how-to-select-from-an-update-target-in-mysql/#comment-19434</link>
		<dc:creator>javaspc</dc:creator>
		<pubDate>Wed, 15 Jun 2011 22:05:16 +0000</pubDate>
		<guid isPermaLink="false">http://www.xaprb.com/blog/?p=174#comment-19434</guid>
		<description>hey men muchas gracias</description>
		<content:encoded><![CDATA[<p>hey men muchas gracias</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: JESUS</title>
		<link>http://www.xaprb.com/blog/2006/06/23/how-to-select-from-an-update-target-in-mysql/#comment-19433</link>
		<dc:creator>JESUS</dc:creator>
		<pubDate>Wed, 15 Jun 2011 19:19:21 +0000</pubDate>
		<guid isPermaLink="false">http://www.xaprb.com/blog/?p=174#comment-19433</guid>
		<description>Hi, I know your are going to help me out, this is the structure of the table, I need to update (ocupado, blouqeado and tamano to &#039;0&#039;) from file_name AA010202 to AA010106 with the script I have it gives me an error, what can i do....????
 
file_id &#124;	file_name &#124;ocupado	 &#124;bloqueado &#124;tamano
  3     &#124; AA010102	 &#124;  1	 &#124;  1	   &#124;  40
  4     &#124; AA010104	 &#124;  1	 &#124;  1	   &#124;  40
  5     &#124; AA010106	 &#124;  0	 &#124;  1	   &#124;  0
  6     &#124; AA010108	 &#124;  0	 &#124;  1	   &#124;  0
  7     &#124; AA010110	 &#124;  0	 &#124;  1	   &#124;  0
  8     &#124; AA010202	 &#124;  1	 &#124;  1	   &#124;  40
  9     &#124; AA010204	 &#124;  0	 &#124;  0	   &#124;  0

UPDATE posiciones 
  SET 
     ocupado = &#039;0&#039;, 
     bloqueado = &#039;0&#039;, 
     tamano = &#039;0&#039; 
  WHERE file_name = 
     (
      SELECT MAX(file_name) 
      FROM posiciones 
      WHERE bloqueado &gt; &#039;0&#039;
     )
  AND file_name =
     (
       SELECT MAX(file_name) 
       FROM posiciones 
       WHERE bloqueado &gt; &#039;0&#039; 
       AND ocupado = &#039;1&#039; 
       AND file_name != 
       (
        SELECT MAX(file_name) 
        FROM posiciones 
        WHERE bloqueado &gt; &#039;0&#039;
       )
     )

by the way THANK YOU a lot just for rading ...!</description>
		<content:encoded><![CDATA[<p>Hi, I know your are going to help me out, this is the structure of the table, I need to update (ocupado, blouqeado and tamano to &#8217;0&#8242;) from file_name AA010202 to AA010106 with the script I have it gives me an error, what can i do&#8230;.????</p>
<p>file_id |	file_name |ocupado	 |bloqueado |tamano<br />
  3     | AA010102	 |  1	 |  1	   |  40<br />
  4     | AA010104	 |  1	 |  1	   |  40<br />
  5     | AA010106	 |  0	 |  1	   |  0<br />
  6     | AA010108	 |  0	 |  1	   |  0<br />
  7     | AA010110	 |  0	 |  1	   |  0<br />
  8     | AA010202	 |  1	 |  1	   |  40<br />
  9     | AA010204	 |  0	 |  0	   |  0</p>
<p>UPDATE posiciones<br />
  SET<br />
     ocupado = &#8217;0&#8242;,<br />
     bloqueado = &#8217;0&#8242;,<br />
     tamano = &#8217;0&#8242;<br />
  WHERE file_name =<br />
     (<br />
      SELECT MAX(file_name)<br />
      FROM posiciones<br />
      WHERE bloqueado &gt; &#8217;0&#8242;<br />
     )<br />
  AND file_name =<br />
     (<br />
       SELECT MAX(file_name)<br />
       FROM posiciones<br />
       WHERE bloqueado &gt; &#8217;0&#8242;<br />
       AND ocupado = &#8217;1&#8242;<br />
       AND file_name !=<br />
       (<br />
        SELECT MAX(file_name)<br />
        FROM posiciones<br />
        WHERE bloqueado &gt; &#8217;0&#8242;<br />
       )<br />
     )</p>
<p>by the way THANK YOU a lot just for rading &#8230;!</p>
]]></content:encoded>
	</item>
</channel>
</rss>

