<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">2014-06-13 19:00 GMT+02:00 Ashutosh Dhundhara <span dir="ltr"><<a href="mailto:ashutoshdhundhara@yahoo.com" target="_blank">ashutoshdhundhara@yahoo.com</a>></span>:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div style="color:#000;background-color:#fff;font-family:arial,helvetica,sans-serif;font-size:10pt"><div><span>Hi,</span></div>
<div style="color:rgb(0,0,0);font-size:13px;font-style:normal;background-color:transparent"><span style="font-family:arial,helvetica,sans-serif">I was working on </span><font><a href="https://sourceforge.net/p/phpmyadmin/feature-requests/861/" target="_blank">RFE #861</a> (Simulate UPDATE query).</font></div>
<div style="color:rgb(0,0,0);font-size:13px;font-style:normal;background-color:transparent"><font>Lets say I have two tables:</font></div><div style="color:rgb(0,0,0);font-size:13px;font-style:normal;font-family:arial,helvetica,sans-serif;background-color:transparent">
<font><br></font></div><div style="color:rgb(0,0,0);font-size:13px;font-style:normal;background-color:transparent"><span style="font-family:'Courier New',courier,monaco,monospace,sans-serif">`table_1`</span></div>
<div style="background-color:transparent"><span style="font-family:'Courier New',courier,monaco,monospace,sans-serif">+----+----------+</span></div><div style="background-color:transparent"><span style="font-family:'Courier New',courier,monaco,monospace,sans-serif">| id | value |</span></div>
<div style="background-color:transparent"><span style="font-family:'Courier New',courier,monaco,monospace,sans-serif">+----+----------+</span></div><div style="background-color:transparent"><span style="font-family:'Courier New',courier,monaco,monospace,sans-serif">| 10 | value_10 |</span></div>
<div style="background-color:transparent"><span style="font-family:'Courier New',courier,monaco,monospace,sans-serif">| 20 | value_20 |</span></div><div style="background-color:transparent"><span style="font-family:'Courier New',courier,monaco,monospace,sans-serif"><font></font></span></div>
<div style="background-color:transparent"><span style="font-family:'Courier New',courier,monaco,monospace,sans-serif">+----+----------+</span></div><div style="color:rgb(0,0,0);font-size:13px;font-family:'Courier New',courier,monaco,monospace,sans-serif;font-style:normal;background-color:transparent">
<span style="font-family:'Courier New',courier,monaco,monospace,sans-serif"><br></span></div><div style="background-color:transparent"><span style="font-family:'Courier New',courier,monaco,monospace,sans-serif">`table_2`</span></div>
<div style="background-color:transparent"><span style="font-family:'Courier New',courier,monaco,monospace,sans-serif">+----+----------+</span></div><div style="background-color:transparent"><span style="font-family:'Courier New',courier,monaco,monospace,sans-serif">| id | value |</span></div>
<div style="background-color:transparent"><span style="font-family:'Courier New',courier,monaco,monospace,sans-serif">+----+----------+</span></div><div style="background-color:transparent"><span style="font-family:'Courier New',courier,monaco,monospace,sans-serif">| 10 | value_10 |</span></div>
<div style="background-color:transparent"><span style="font-family:'Courier New',courier,monaco,monospace,sans-serif">| 20 | value_20 |</span></div><div style="background-color:transparent"><span style="font-family:'Courier New',courier,monaco,monospace,sans-serif"><font></font></span></div>
<div style="font-family:'Courier New',courier,monaco,monospace,sans-serif;background-color:transparent"><span></span></div><div style="background-color:transparent"><span style="font-family:'Courier New',courier,monaco,monospace,sans-serif">+----+----------+</span></div>
<div style="color:rgb(0,0,0);font-size:13px;font-family:'Courier New',courier,monaco,monospace,sans-serif;font-style:normal;background-color:transparent"><span style="font-family:'Courier New',courier,monaco,monospace,sans-serif"><br>
</span></div><div style="color:rgb(0,0,0);font-size:13px;font-style:normal;background-color:transparent"><span>UPDATE Query</span><span style="font-family:'Courier New',courier,monaco,monospace,sans-serif">: UPDATE table_1, table_2 SET table_1.value = 'NEW_VALUE', table_2.value='NEW_VALUE' WHERE <a href="http://table_1.id" target="_blank">table_1.id</a> > 10 AND <a href="http://table_2.id" target="_blank">table_2.id</a> > 10;</span></div>
<div style="color:rgb(0,0,0);font-size:13px;font-style:normal;background-color:transparent"><span><br></span></div><div style="color:rgb(0,0,0);font-size:13px;font-style:normal;font-family:arial,helvetica,sans-serif;background-color:transparent">
<span>This will affect 2 rows.</span></div><div style="color:rgb(0,0,0);font-size:13px;font-family:'Courier New',courier,monaco,monospace,sans-serif;font-style:normal;background-color:transparent"><span style="font-family:'Courier New',courier,monaco,monospace,sans-serif"><br>
</span></div><div style="color:rgb(0,0,0);font-size:13px;font-family:'Courier New',courier,monaco,monospace,sans-serif;font-style:normal;background-color:transparent">How to simulate this query using SELECT statement?</div>
<div style="color:rgb(0,0,0);font-size:13px;font-family:'Courier New',courier,monaco,monospace,sans-serif;font-style:normal;background-color:transparent"><br></div><div style="color:rgb(0,0,0);font-size:13px;font-family:'Courier New',courier,monaco,monospace,sans-serif;font-style:normal;background-color:transparent">
I was trying:</div><div style="color:rgb(0,0,0);font-size:13px;font-family:'Courier New',courier,monaco,monospace,sans-serif;font-style:normal;background-color:transparent"><br></div><div style="color:rgb(0,0,0);font-size:13px;font-style:normal;background-color:transparent">
<span style="color:rgb(34,34,34);font-family:'Courier New',courier,monaco,monospace,sans-serif">SELECT DISTINCT table_1.value, table_2.value FROM table_1, table_2 WHERE table_1.value <>
'NEW_VALUE' AND table_2.value <> 'NEW_VAUE' AND <a href="http://table_1.id" target="_blank">table_1.id</a> > 10 AND <a href="http://table_2.id" target="_blank">table_2.id</a> > 10;</span><br>
</div><div style="color:rgb(0,0,0);font-size:13px;font-style:normal;font-family:arial,helvetica,sans-serif;background-color:transparent"><span style="color:rgb(34,34,34);font-family:'Courier New',courier,monaco,monospace,sans-serif"><br>
</span></div><div style="color:rgb(34,34,34);font-size:13px;font-style:normal;background-color:transparent"><span style="color:rgb(34,34,34)">but this only returns 1 row.</span></div><div style="color:rgb(34,34,34);font-size:13px;font-style:normal;font-family:arial,helvetica,sans-serif;background-color:transparent">
<span style="color:rgb(34,34,34)">Can this be done in a single query only?</span></div><div></div><div> </div><div>Regards,
<br>Ashutosh Dhundhara</div></div></div></blockquote></div><br></div><div class="gmail_extra">Hi,</div><div class="gmail_extra"><br></div><div class="gmail_extra">Isn't it possible to run the query with </div><div class="gmail_extra">
set AUTOCOMMIT=0;</div><div class="gmail_extra">and a rollback at the end?</div><div class="gmail_extra"><br></div><div class="gmail_extra">Hugues.</div></div>