﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>BlogJava-Java,永远不敢言精通-随笔分类-MySql</title><link>http://www.blogjava.net/crazycoding/category/45547.html</link><description>God helps those who help themselves. </description><language>zh-cn</language><lastBuildDate>Fri, 09 Jul 2010 13:04:31 GMT</lastBuildDate><pubDate>Fri, 09 Jul 2010 13:04:31 GMT</pubDate><ttl>60</ttl><item><title>MYSQL——[Error Code : 1064]</title><link>http://www.blogjava.net/crazycoding/archive/2010/07/09/325682.html</link><dc:creator>Ying-er</dc:creator><author>Ying-er</author><pubDate>Fri, 09 Jul 2010 12:57:00 GMT</pubDate><guid>http://www.blogjava.net/crazycoding/archive/2010/07/09/325682.html</guid><wfw:comment>http://www.blogjava.net/crazycoding/comments/325682.html</wfw:comment><comments>http://www.blogjava.net/crazycoding/archive/2010/07/09/325682.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/crazycoding/comments/commentRss/325682.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/crazycoding/services/trackbacks/325682.html</trackback:ping><description><![CDATA[删除数据库中的重复记录<br />
SqlServer：<br />
<div style="background-color: #eeeeee; font-size: 13px; border: 1px solid #cccccc; padding: 4px 5px 4px 4px; width: 98%;"><!--<br />
<br />
Code highlighting produced by Actipro CodeHighlighter (freeware)<br />
http://www.CodeHighlighter.com/<br />
<br />
--><span style="color: #0000ff;">delete</span><span style="color: #000000;">&nbsp;</span><span style="color: #0000ff;">from</span><span style="color: #000000;">&nbsp;team&nbsp;</span><span style="color: #0000ff;">where</span><span style="color: #000000;">&nbsp;id&nbsp;</span><span style="color: #808080;">in</span><span style="color: #000000;">&nbsp;(</span><span style="color: #0000ff;">select</span><span style="color: #000000;">&nbsp;</span><span style="color: #ff00ff;">min</span><span style="color: #000000;">(id)&nbsp;</span><span style="color: #0000ff;">from</span><span style="color: #000000;">&nbsp;team&nbsp;</span><span style="color: #0000ff;">group</span><span style="color: #000000;">&nbsp;</span><span style="color: #0000ff;">by</span><span style="color: #000000;">&nbsp;</span><span style="color: #ff0000;">[</span><span style="color: #ff0000;">name</span><span style="color: #ff0000;">]</span><span style="color: #000000;">&nbsp;</span><span style="color: #0000ff;">having</span><span style="color: #000000;">&nbsp;</span><span style="color: #ff00ff;">count</span><span style="color: #000000;">(id)&nbsp;</span><span style="color: #808080;">&gt;</span><span style="color: #000000;">&nbsp;</span><span style="color: #800000; font-weight: bold;">1</span><span style="color: #000000;">)</span></div>
MySql：<br />
<p>Error Code : 1064<br />
You have an error in your SQL syntax; check the manual
that corresponds to your MySQL server version for the right syntax to use near
'[name] having count(id) &gt; 1)' at line 1<br />
(0 ms taken)</p>
<p>so：</p>
<div style="background-color: #eeeeee; font-size: 13px; border: 1px solid #cccccc; padding: 4px 5px 4px 4px; width: 98%;"><!--<br />
<br />
Code highlighting produced by Actipro CodeHighlighter (freeware)<br />
http://www.CodeHighlighter.com/<br />
<br />
--><span style="color: #0000ff;">create</span><span style="color: #000000;">&nbsp;</span><span style="color: #0000ff;">temporary</span><span style="color: #000000;">&nbsp;</span><span style="color: #0000ff;">table</span><span style="color: #000000;">&nbsp;tmp_wrap&nbsp;</span><span style="color: #0000ff;">select</span><span style="color: #000000;">&nbsp;</span><span style="color: #808080;">*</span><span style="color: #000000;">&nbsp;</span><span style="color: #0000ff;">from</span><span style="color: #000000;">&nbsp;users_groups&nbsp;</span><span style="color: #0000ff;">group</span><span style="color: #000000;">&nbsp;</span><span style="color: #0000ff;">by</span><span style="color: #000000;">&nbsp;uid&nbsp;</span><span style="color: #0000ff;">having</span><span style="color: #000000;">&nbsp;</span><span style="color: #ff00ff;">count</span><span style="color: #000000;">(</span><span style="color: #800000; font-weight: bold;">1</span><span style="color: #000000;">)&nbsp;</span><span style="color: #808080;">&gt;=</span><span style="color: #000000;">&nbsp;</span><span style="color: #800000; font-weight: bold;">1</span><span style="color: #000000;">;<br />
</span></div>
<br />
<div style="background-color: #eeeeee; font-size: 13px; border: 1px solid #cccccc; padding: 4px 5px 4px 4px; width: 98%;"><!--<br />
<br />
Code highlighting produced by Actipro CodeHighlighter (freeware)<br />
http://www.CodeHighlighter.com/<br />
<br />
--><span style="color: #0000ff;">truncate</span><span style="color: #000000;">&nbsp;</span><span style="color: #0000ff;">table</span><span style="color: #000000;">&nbsp;users_groups;<br />
</span></div>
<br />
<div style="background-color: #eeeeee; font-size: 13px; border: 1px solid #cccccc; padding: 4px 5px 4px 4px; width: 98%;"><!--<br />
<br />
Code highlighting produced by Actipro CodeHighlighter (freeware)<br />
http://www.CodeHighlighter.com/<br />
<br />
--><span style="color: #0000ff;">insert</span><span style="color: #000000;">&nbsp;</span><span style="color: #0000ff;">into</span><span style="color: #000000;">&nbsp;users_groups&nbsp;</span><span style="color: #0000ff;">select</span><span style="color: #000000;">&nbsp;</span><span style="color: #808080;">*</span><span style="color: #000000;">&nbsp;</span><span style="color: #0000ff;">from</span><span style="color: #000000;">&nbsp;tmp_wrap;<br />
</span></div>
<br />
<div style="background-color: #eeeeee; font-size: 13px; border: 1px solid #cccccc; padding: 4px 5px 4px 4px; width: 98%;"><!--<br />
<br />
Code highlighting produced by Actipro CodeHighlighter (freeware)<br />
http://www.CodeHighlighter.com/<br />
<br />
--><span style="color: #0000ff;">drop</span><span style="color: #000000;">&nbsp;</span><span style="color: #0000ff;">table</span><span style="color: #000000;">&nbsp;tmp_wrap;<br />
</span></div>
<br />
OR：<br />
<div style="background-color: #eeeeee; font-size: 13px; border: 1px solid #cccccc; padding: 4px 5px 4px 4px; width: 98%;"><!--<br />
<br />
Code highlighting produced by Actipro CodeHighlighter (freeware)<br />
http://www.CodeHighlighter.com/<br />
<br />
--><span style="color: #0000ff;">delete</span><span style="color: #000000;">&nbsp;team&nbsp;</span><span style="color: #0000ff;">as</span><span style="color: #000000;">&nbsp;a&nbsp;</span><span style="color: #0000ff;">from</span><span style="color: #000000;">&nbsp;team&nbsp;</span><span style="color: #0000ff;">as</span><span style="color: #000000;">&nbsp;a,(</span><span style="color: #0000ff;">select</span><span style="color: #000000;">&nbsp;</span><span style="color: #ff00ff;">min</span><span style="color: #000000;">(id)&nbsp;</span><span style="color: #0000ff;">as</span><span style="color: #000000;">&nbsp;id,`name`&nbsp;</span><span style="color: #0000ff;">from</span><span style="color: #000000;">&nbsp;team&nbsp;</span><span style="color: #0000ff;">group</span><span style="color: #000000;">&nbsp;</span><span style="color: #0000ff;">by</span><span style="color: #000000;">&nbsp;`name`&nbsp;</span><span style="color: #0000ff;">having</span><span style="color: #000000;">&nbsp;</span><span style="color: #ff00ff;">count</span><span style="color: #000000;">(id)&nbsp;</span><span style="color: #808080;">&gt;</span><span style="color: #000000;">&nbsp;</span><span style="color: #800000; font-weight: bold;">1</span><span style="color: #000000;">)&nbsp;</span><span style="color: #0000ff;">as</span><span style="color: #000000;">&nbsp;b&nbsp;</span><span style="color: #0000ff;">where</span><span style="color: #000000;">&nbsp;a.id</span><span style="color: #808080;">=</span><span style="color: #000000;">b.id&nbsp;</span><span style="color: #808080;">and</span><span style="color: #000000;">&nbsp;a.`name`</span><span style="color: #808080;">=</span><span style="color: #000000;">b.`name` <br />
</span></div>
<br />
<br />
<img src ="http://www.blogjava.net/crazycoding/aggbug/325682.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/crazycoding/" target="_blank">Ying-er</a> 2010-07-09 20:57 <a href="http://www.blogjava.net/crazycoding/archive/2010/07/09/325682.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>