2017-02-02 13 views
-1

私のSQLテーブルのxmlカラムに重複するエントリがありますmaterial8 key.Iを参照してくださいentry.Iを削除しています。 。mysqlのxmlで重複したエントリを削除します

Update mytable set xml = replace (xml, "<Book key=\"material8\" active=\"true\" displayOrder=\"5\" />", "") where id = 9 and type_key="mykey1"; 


<?xml version="1.0" encoding="UTF-8"?> 
<Type key="test1" publicKey="test2" > 
    <UIProperties> 
     <label locale="en_US">My book</label> 
    </UIProperties> 
    <Books> 
     <Book key="material1" active="true" displayOrder="0" > 
      <UIProperties> 
       <label locale="en_US">My Books</label> 
      </UIProperties> 
     </Book> 
     <Book key="material2" /> 
     <Book key="material3" active="true" displayOrder="3" > 
      <Pages> 
       <Page key="material4" active="true" displayOrder="0" /> 
       <Page key="material5" active="true" displayOrder="1" /> 
      </Pages> 
     </Book> 
     <Book key="material6" active="true" displayOrder="4" /> 
     <Book key="material7" active="true" displayOrder="2" /> 
     <Book key="material8" active="true" displayOrder="5" /> 
     <Book key="material8" active="true" displayOrder="5" /> 
    </Books> 
    <Attributes> 
     <Attribute key="desc" /> 
     <Attribute key="date1" /> 
     <Attribute key="date2" /> 
    </Attributes> 
</Type> 
+1

"" – Veve

+0

で "のR \ \ N " を交換してくださいあなたは私の解決策を見たことがありますか?それはあなたを助けましたか? – Veve

答えて

0

簡単な解決策は、誰にも負けない代わりに1の、1に2冊の本を交換することである。

UPDATE mytable 
SET xml = REPLACE(xml, "<Book key=\"material8\" active=\"true\" displayOrder=\"5\" /><Book key=\"material8\" active=\"true\" displayOrder=\"5\" />", "<Book key=\"material8\" active=\"true\" displayOrder=\"5\" />") 
WHERE id = 9 
AND type_key="mykey1"; 
関連する問題