Rumah >pangkalan data >tutorial mysql >Bagaimanakah saya boleh mengalih keluar tag HTML daripada pangkalan data MySQL?
MySQL Query to Remove HTML Tags
You have a substantial database filled with records containing HTML tags (). Removing these tags is essential. While PHP provides the strip_tags method, running a PHP script to modify all the records can be time-consuming.
MySQL Solution
MySQL version 5.5 and later offer XML functions that can address this issue:
SELECT ExtractValue(field, '//text()') FROM table;
This query extracts only the text content from the specified "field" column in the "table." It relies on the XML functions provided by MySQL to parse the HTML tags and retrieve the text content.
Reference
For more details on XML functions in MySQL, refer to the official documentation:
https://dev.mysql.com/doc/refman/5.5/en/xml-functions.html
Atas ialah kandungan terperinci Bagaimanakah saya boleh mengalih keluar tag HTML daripada pangkalan data MySQL?. Untuk maklumat lanjut, sila ikut artikel berkaitan lain di laman web China PHP!