<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Domanda mysql]]></title><description><![CDATA[<p dir="auto">Ho questa tabella:</p>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>tipo</th>
<th>valore</th>
<th>id</th>
</tr>
</thead>
<tbody>
<tr>
<td>-1</td>
<td></td>
<td>1</td>
</tr>
<tr>
<td>-2</td>
<td></td>
<td>2</td>
</tr>
<tr>
<td>-2</td>
<td></td>
<td>3</td>
</tr>
<tr>
<td>-1</td>
<td></td>
<td>4</td>
</tr>
<tr>
<td>-2</td>
<td></td>
<td>5</td>
</tr>
<tr>
<td>-1</td>
<td></td>
<td>6</td>
</tr>
<tr>
<td>-2</td>
<td></td>
<td>7</td>
</tr>
<tr>
<td>-2</td>
<td></td>
<td>8</td>
</tr>
<tr>
<td>-2</td>
<td></td>
<td>9</td>
</tr>
</tbody>
</table>
<p dir="auto">Come faccio a settare con UPDATE tutti i campi che hanno valore -2 sull'id del precedente e più vicino valore -1? Visivamente è più semplice, ecco come dovrebbe diventare:</p>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>tipo</th>
<th>valore</th>
<th>id</th>
</tr>
</thead>
<tbody>
<tr>
<td>-1</td>
<td></td>
<td>1</td>
</tr>
<tr>
<td>-2</td>
<td>1</td>
<td>2</td>
</tr>
<tr>
<td>-2</td>
<td>1</td>
<td>3</td>
</tr>
<tr>
<td>-1</td>
<td></td>
<td>4</td>
</tr>
<tr>
<td>-2</td>
<td>4</td>
<td>5</td>
</tr>
<tr>
<td>-1</td>
<td></td>
<td>6</td>
</tr>
<tr>
<td>-2</td>
<td>6</td>
<td>7</td>
</tr>
<tr>
<td>-2</td>
<td>6</td>
<td>8</td>
</tr>
<tr>
<td>-2</td>
<td>6</td>
<td>9</td>
</tr>
</tbody>
</table>
<p dir="auto">Grazie in anticipo!</p>
]]></description><link>https://dev.connect.gt/topic/188448/domanda-mysql</link><generator>RSS for Node</generator><lastBuildDate>Wed, 25 Nov 2026 21:08:47 GMT</lastBuildDate><atom:link href="https://dev.connect.gt/topic/188448.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 29 Apr 2013 09:20:29 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Domanda mysql on Tue, 30 Apr 2013 08:16:22 GMT]]></title><description><![CDATA[<p dir="auto">Purtroppo da manuale di mysql non puoi fare una cosa del genere...<br />
A prescindere che dovresti fare una subquery...<br />
Se la tabella fosse piccole forse potresti cercare nella sub qualcosa... il discorso però è che essendo i parametri molto variabili e senza una schema devi temo per forza passare da un linguaggio di programmazione =/</p>
]]></description><link>https://dev.connect.gt/post/1122717</link><guid isPermaLink="true">https://dev.connect.gt/post/1122717</guid><dc:creator><![CDATA[catsinger]]></dc:creator><pubDate>Tue, 30 Apr 2013 08:16:22 GMT</pubDate></item><item><title><![CDATA[Reply to Domanda mysql on Tue, 30 Apr 2013 08:10:06 GMT]]></title><description><![CDATA[<p dir="auto">Si come puoi vedere l'id viene riportato sulle row sottostanti fino al successivo. Purtroppo è questo che ho bisogno e questo è solo un esempio, la tabella su cui devo effettuare questa operazione è immensa, non posso farlo a mano e poi se fosse stato un semplice update l'avrei fatto da solo <img src="https://dev.connect.gt/assets/plugins/nodebb-plugin-emoji/emoji/android/1f604.png?v=12b9555a9a1" class="not-responsive emoji emoji-android emoji--smile" style="height:1.4em;width:auto;vertical-align:middle" title=":D" alt="😄" /></p>
]]></description><link>https://dev.connect.gt/post/1122714</link><guid isPermaLink="true">https://dev.connect.gt/post/1122714</guid><dc:creator><![CDATA[ruttan]]></dc:creator><pubDate>Tue, 30 Apr 2013 08:10:06 GMT</pubDate></item><item><title><![CDATA[Reply to Domanda mysql on Tue, 30 Apr 2013 07:19:00 GMT]]></title><description><![CDATA[<p dir="auto">Ho capito che vuoi modificare tutti i campi con tipo diverso da -1...<br />
Ma che valore ci vuoi mettere? L'id dell'ultimo con -1? o_0</p>
]]></description><link>https://dev.connect.gt/post/1122715</link><guid isPermaLink="true">https://dev.connect.gt/post/1122715</guid><dc:creator><![CDATA[catsinger]]></dc:creator><pubDate>Tue, 30 Apr 2013 07:19:00 GMT</pubDate></item><item><title><![CDATA[Reply to Domanda mysql on Mon, 29 Apr 2013 15:04:27 GMT]]></title><description><![CDATA[<p dir="auto">Spiegarlo è più complesso che vederlo. Ecco così in grassetto magari si capisce meglio che l'id delle row con tipo uguale a -1 vieni riportato sulla colonna valore di tutte le row con tipo uguale a -2 sottostanti fino alla successiva row con tipo uguale a -1:</p>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>tipo</th>
<th>valore</th>
<th>id</th>
</tr>
</thead>
<tbody>
<tr>
<td>-1</td>
<td></td>
<td><strong>1</strong></td>
</tr>
<tr>
<td>-2</td>
<td><strong>1</strong></td>
<td>2</td>
</tr>
<tr>
<td>-2</td>
<td><strong>1</strong></td>
<td>3</td>
</tr>
<tr>
<td>-1</td>
<td></td>
<td><strong>4</strong></td>
</tr>
<tr>
<td>-2</td>
<td><strong>4</strong></td>
<td>5</td>
</tr>
<tr>
<td>-1</td>
<td></td>
<td><strong>6</strong></td>
</tr>
<tr>
<td>-2</td>
<td><strong>6</strong></td>
<td>7</td>
</tr>
<tr>
<td>-2</td>
<td><strong>6</strong></td>
<td>8</td>
</tr>
<tr>
<td>-2</td>
<td><strong>6</strong></td>
<td>9</td>
</tr>
</tbody>
</table>
]]></description><link>https://dev.connect.gt/post/1122713</link><guid isPermaLink="true">https://dev.connect.gt/post/1122713</guid><dc:creator><![CDATA[ruttan]]></dc:creator><pubDate>Mon, 29 Apr 2013 15:04:27 GMT</pubDate></item><item><title><![CDATA[Reply to Domanda mysql on Mon, 29 Apr 2013 13:10:17 GMT]]></title><description><![CDATA[<blockquote>
<p dir="auto"><strong>ruttan</strong></p>
<p dir="auto">Ho questa tabella:</p>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>tipo</th>
<th>valore</th>
<th>id</th>
</tr>
</thead>
<tbody>
<tr>
<td>-1</td>
<td></td>
<td>1</td>
</tr>
<tr>
<td>-2</td>
<td></td>
<td>2</td>
</tr>
<tr>
<td>-2</td>
<td></td>
<td>3</td>
</tr>
<tr>
<td>-1</td>
<td></td>
<td>4</td>
</tr>
<tr>
<td>-2</td>
<td></td>
<td>5</td>
</tr>
<tr>
<td>-1</td>
<td></td>
<td>6</td>
</tr>
<tr>
<td>-2</td>
<td></td>
<td>7</td>
</tr>
<tr>
<td>-2</td>
<td></td>
<td>8</td>
</tr>
<tr>
<td>-2</td>
<td></td>
<td>9</td>
</tr>
</tbody>
</table>
<p dir="auto">Come faccio a settare con UPDATE tutti i campi che hanno valore -2 sull'id del precedente e più vicino valore -1? Visivamente è più semplice, ecco come dovrebbe diventare:</p>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>tipo</th>
<th>valore</th>
<th>id</th>
</tr>
</thead>
<tbody>
<tr>
<td>-1</td>
<td></td>
<td>1</td>
</tr>
<tr>
<td>-2</td>
<td>1</td>
<td>2</td>
</tr>
<tr>
<td>-2</td>
<td>1</td>
<td>3</td>
</tr>
<tr>
<td>-1</td>
<td></td>
<td>4</td>
</tr>
<tr>
<td>-2</td>
<td>4</td>
<td>5</td>
</tr>
<tr>
<td>-1</td>
<td></td>
<td>6</td>
</tr>
<tr>
<td>-2</td>
<td>6</td>
<td>7</td>
</tr>
<tr>
<td>-2</td>
<td>6</td>
<td>8</td>
</tr>
<tr>
<td>-2</td>
<td>6</td>
<td>9</td>
</tr>
</tbody>
</table>
<p dir="auto">Grazie in anticipo!</p>
</blockquote>
<p dir="auto">Sinceramente non ho capito che vuoi fare o_o<br />
Ad ogni modo è una semplice query di tipo update con clausola where</p>
]]></description><link>https://dev.connect.gt/post/1122716</link><guid isPermaLink="true">https://dev.connect.gt/post/1122716</guid><dc:creator><![CDATA[catsinger]]></dc:creator><pubDate>Mon, 29 Apr 2013 13:10:17 GMT</pubDate></item></channel></rss>