2016-05-24 8 views
1

Magentoサイトでは、各製品の解読フィールドに<a href="link">Content</a>のようなアンカータグがあります。MySQLアップデート「description」のすべてのフィールドから特定のHtmlタグを削除するクエリ

ここで、このアンカータグをタグ内のコンテンツとともに削除しますが、残りの説明はそのままです。

は今サンプル記述は以下のようなものです:

<ul> 
    <li>Cylinder head has been assembled to OEM specifications with using all new components like Cam shaft, valves and/or springs, buckets, shims etc. where applicable.</li> 
    <li> 
     <a href="http://sampledomain.com/media/wysiwyg/folder/file.pdf">All heads we supply pass through 24 points of quality check program.</a> 
    </li> 
    <li>Warranty: 1 year or 20,000 Kms factory warranty.</li> 
    <li> 
     <b>Kit Includes:</b> 
    </li> 
    <li>Fully assembled cylinder head</li> 
    <li>VRS (Vehicle regrind set)</li> 
    <li>Head gaskets (thickest grade)</li> 
    <li>Head bolts</li> 
    <li>Warranty card</li> 
</ul> 

今私はそれが以下のように表示したい:

<ul> 
    <li>Cylinder head has been assembled to OEM specifications with using all new components like Cam shaft, valves and/or springs, buckets, shims etc. where applicable.</li> 
    <li> 
    </li> 
    <li>Warranty: 1 year or 20,000 Kms factory warranty.</li> 
    <li> 
     <b>Kit Includes:</b> 
    </li> 
    <li>Fully assembled cylinder head</li> 
    <li>VRS (Vehicle regrind set)</li> 
    <li>Head gaskets (thickest grade)</li> 
    <li>Head bolts</li> 
    <li>Warranty card</li> 
</ul> 

私は更新クエリでこれを行うことができますどのように?

+0

アンカータグが1つだけ含まれているか、製品ごとに複数存在しますか? – Chella

+0

実際のサンプルと必要な結果を表示します。 – scaisEdge

+0

商品説明ごとにアンカータグが1つだけあります。私の質問を更新して説明を追加する。 –

答えて

0

これは仕事をします.. ..!

UPDATE your_table_name 
set description = 
concat 
(
substring_index(description, '<a',1), 
substring_index(description, '</a>',-1) 
); 
+0

しかし、異なる製品は異なる記述を持っているので、私は正規表現が良いと思ったのです。 –

+0

あなたの答えはレコードを選択するのに適しています。これに更新するクエリを追加することはできますか? –

関連する問題