<?xml version='1.0' encoding="utf-8"?>
      <rss version='2.0'>
      <channel>
      <title>Форум на Исходниках.RU</title>
      <link>https://forum.sources.ru</link>
      <description>Форум на Исходниках.RU</description>
      <generator>Форум на Исходниках.RU</generator>
  	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=412891&amp;view=findpost&amp;p=3770878</guid>
        <pubDate>Fri, 01 Jun 2018 16:30:26 +0000</pubDate>
        <title>MySQL, хитрый запрос2</title>
        <link>https://forum.sources.ru/index.php?showtopic=412891&amp;view=findpost&amp;p=3770878</link>
        <description><![CDATA[Gonarh: Оно. Вот так меня устроило<br>
<div class='tag-code'><span class='pre_code'></span><div class='code  code_collapsed ' title='Подсветка синтаксиса доступна зарегистрированным участникам Форума.' style=''><div><div><ol type="1"><div class="code_line">DELETE t1, t2</div><div class="code_line">FROM t1, t2, (SELECT t2.uid</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; FROM t2</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; GROUP BY t2.uid</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; HAVING (SUM(t2.comment=&#39;foo&#39; AND t2.check_variant&#60;100) = 0) AND (SUM(t2.comment=&#39;bar&#39; AND t2.check_variant&#60;100) &#62; 3)</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;) t3</div><div class="code_line">WHERE t1.ID = t2.uid</div><div class="code_line">&nbsp;AND t2.uid = t3.uid</div></ol></div></div></div></div><script>preloadCodeButtons('1');</script>]]></description>
        <author>Gonarh</author>
        <category>Базы данных: SQL</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=412891&amp;view=findpost&amp;p=3770846</guid>
        <pubDate>Fri, 01 Jun 2018 11:03:22 +0000</pubDate>
        <title>MySQL, хитрый запрос2</title>
        <link>https://forum.sources.ru/index.php?showtopic=412891&amp;view=findpost&amp;p=3770846</link>
        <description><![CDATA[Akina: <div class='tag-code'><span class='pre_code'></span><div class='code  code_collapsed ' title='Подсветка синтаксиса доступна зарегистрированным участникам Форума.' style=''><div><div><ol type="1"><div class="code_line">DELETE t1, t2</div><div class="code_line">FROM t1, t2, (SELECT t2.uid</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;FROM t2</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;GROUP BY t2.uid</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;HAVING SUM(t2.comment=&#39;foo&#39; AND t2.check_variant&#60;100) = 0</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ) t3</div><div class="code_line">WHERE t1.ID = t2.uid</div><div class="code_line">&nbsp;&nbsp;AND t2.uid = t3.uid</div></ol></div></div></div></div>?]]></description>
        <author>Akina</author>
        <category>Базы данных: SQL</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=412891&amp;view=findpost&amp;p=3770842</guid>
        <pubDate>Fri, 01 Jun 2018 10:31:17 +0000</pubDate>
        <title>MySQL, хитрый запрос2</title>
        <link>https://forum.sources.ru/index.php?showtopic=412891&amp;view=findpost&amp;p=3770842</link>
        <description><![CDATA[Gonarh: Посмотрел, почти то что надо, получилось такое<br>
<br>
<div class='tag-code'><span class='pre_code'></span><div class='code  code_collapsed ' title='Подсветка синтаксиса доступна зарегистрированным участникам Форума.' style=''><div><div><ol type="1"><div class="code_line">DELETE t1, t2</div><div class="code_line">FROM t1</div><div class="code_line">INNER JOIN t2 ON t1.ID = t2.uid</div><div class="code_line">WHERE t2.comment&#60;&#62;&#39;foo&#39; AND &nbsp;t2.check_variant&#60;100;</div></ol></div></div></div></div><br>
<div class="tag-mod"><div class="tag-mod__prefix">M</div><div class="tag-mod__body">Просьба оформлять SQL тегом CODE</div></div><br>
если бы не одно но.<br>
При условии наличия table2.comment=&#39;foo&#39; AND table2.check_variant&lt;100 удалять ВООБЩЕ ничего не надо, а такое условие просто не учитывается.]]></description>
        <author>Gonarh</author>
        <category>Базы данных: SQL</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=412891&amp;view=findpost&amp;p=3770836</guid>
        <pubDate>Fri, 01 Jun 2018 09:57:15 +0000</pubDate>
        <title>MySQL, хитрый запрос2</title>
        <link>https://forum.sources.ru/index.php?showtopic=412891&amp;view=findpost&amp;p=3770836</link>
        <description><![CDATA[JoeUser: <div class='tag-quote'><a class='tag-quote-link' href='https://forum.sources.ru/index.php?showtopic=412891&view=findpost&p=3770833'><span class='tag-quote-prefix'>Цитата</span></a> <span class='tag-quote__quote-info'>Gonarh &#064; <time class="tag-quote__quoted-time" datetime="2018-06-01T09:07:35+00:00">01.06.18, 09:07</time></span><div class='quote '>Можно ли такое упихать в один запрос?</div></div><br>
Попробуй самостоятельно по мануалу: <a class='tag-url' href='http://www.mysqltutorial.org/mysql-delete-join/' target='_blank'>http://www.mysqltutorial.org/mysql-delete-join/</a>]]></description>
        <author>JoeUser</author>
        <category>Базы данных: SQL</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=412891&amp;view=findpost&amp;p=3770833</guid>
        <pubDate>Fri, 01 Jun 2018 09:07:35 +0000</pubDate>
        <title>MySQL, хитрый запрос2</title>
        <link>https://forum.sources.ru/index.php?showtopic=412891&amp;view=findpost&amp;p=3770833</link>
        <description><![CDATA[Gonarh: Сабж. Даны две таблицы<br>
Первая <br>
<div class='tag-code'><span class='pre_code'></span><div class='code  code_collapsed ' title='Подсветка синтаксиса доступна зарегистрированным участникам Форума.' style=''><div><div><ol type="1"><div class="code_line">CREATE TABLE IF NOT EXISTS `table1` (</div><div class="code_line">&nbsp;&nbsp;`ID` int(11) NOT NULL AUTO_INCREMENT,</div><div class="code_line">&nbsp;&nbsp;`uid` int(11) NOT NULL,</div><div class="code_line">&nbsp;&nbsp;PRIMARY KEY (`ID`)</div><div class="code_line">) ;</div></ol></div></div></div></div><br>
Вторая, связана с первой &quot;многие к одному&quot; по полю uid<br>
<div class='tag-code'><span class='pre_code'></span><div class='code  code_collapsed ' title='Подсветка синтаксиса доступна зарегистрированным участникам Форума.' style=''><div><div><ol type="1"><div class="code_line">CREATE TABLE IF NOT EXISTS `table2` (</div><div class="code_line">&nbsp;&nbsp;`id` int(11) NOT NULL AUTO_INCREMENT,</div><div class="code_line">&nbsp;&nbsp;`uid` int(11) NOT NULL,</div><div class="code_line">&nbsp;&nbsp;`check_variant` int(10) unsigned NOT NULL,</div><div class="code_line">&nbsp;&nbsp;`comment` varchar(512) COLLATE utf8_unicode_ci NOT NULL DEFAULT &#39;&#39;,</div><div class="code_line">&nbsp;&nbsp;PRIMARY KEY (`id`)</div><div class="code_line">);</div></ol></div></div></div></div><br>
<br>
Задача: удалить строки в обоих таблицах при условии table2.comment&lt;&gt;&#39;foo&#39; AND table2.check_variant&lt;100 AND table1.ID=table2.uid<br>
Можно ли такое упихать в один запрос?]]></description>
        <author>Gonarh</author>
        <category>Базы данных: SQL</category>
      </item>
	
      </channel>
      </rss>
	