<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<div class="moz-cite-prefix">On 01/21/15 05:31, Stephen Worthington
wrote:<br>
</div>
<blockquote
cite="mid:mailman.161.1421839917.1060.mythtv-users@mythtv.org"
type="cite">
<pre wrap="">
So I seem to somehow have acquired 20 rows with duplicate primary
keys. Fortunately, all the data values are also duplicated, so it
should not be causing me any problems as long as I never have to
change one of those settings. Now I need to work out just how to fix
this - my current thought is to dump the settings table, edit out all
the duplicates from the SQL in the dump, then drop the table and
restore it from the edited dump. Are there any better ideas?</pre>
</blockquote>
<br>
How about:<br>
<br>
<blockquote>delete from settings where value = 'BackendServerPort'
and hostname = 'mypvr' limit 1;<br>
</blockquote>
<br>
This will only delete one value, regardless of how many match the
where clause.<br>
<br>
You would have to do this manually for each value, or you could
generate the commands:<br>
<br>
<blockquote>mysql -BN -h mypvr mythconverg -e 'select value,hostname
from settings group by value,hostname having count(value) > 1'
| perl -n -e '($value,$host) = split; print "delete from settings
where value = \"$value\" and hostname = \"$host\" limit1;\n"'<br>
</blockquote>
<br>
Review the output and if you like the result, then feed the SQL
statements to a mysql command.<br>
<br>
Keith<br>
</body>
</html>