What is the MySQL query equivalent of PHP strip_tags?(与 PHP strip_tags 等效的 MySQL 查询是什么?)
问题描述
我有一个大型数据库,其中包含带有 标签的记录,我想删除它们.当然有一种方法,我创建一个全选的PHP脚本,使用
strip_tags
并更新数据库,但这需要很长时间.那么如何使用简单(或复杂)的 MySQL 查询来做到这一点?
I have a large database which contains records that have <a>
tags in them and I would like to remove them. Of course there is the method where I create a PHP script that selects all, uses strip_tags
and updates the database, but this takes a long time. So how can I do this with a simple (or complicated) MySQL query?
推荐答案
我认为仅在 MySQL 中没有任何有效的方法可以做到这一点.
I don't believe there's any efficient way to do this in MySQL alone.
MySQL 确实有一个 REPLACE()
函数,但它只能替换常量字符串,不能替换模式.您可能会编写一个 MySQL 存储函数来搜索和替换标签,但此时您最好编写一个 PHP 脚本来完成这项工作.它可能没有相当那么快,但编写起来可能会更快.
MySQL does have a REPLACE()
function, but it can only replace constant strings, not patterns. You could possibly write a MySQL stored function to search for and replace tags, but at that point you're probably better off writing a PHP script to do the job. It might not be quite as fast, but it will probably be faster to write.
这篇关于与 PHP strip_tags 等效的 MySQL 查询是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:与 PHP strip_tags 等效的 MySQL 查询是什么?


- 如何使用 pip 安装 Python MySQLdb 模块? 2021-01-01
- 以一个值为轴心,但将一行上的数据按另一行分组? 2022-01-01
- 更改自动增量起始编号? 2021-01-01
- 如何将 SonarQube 6.7 从 MySQL 迁移到 postgresql 2022-01-01
- 如何将 Byte[] 插入 SQL Server VARBINARY 列 2021-01-01
- 远程 mySQL 连接抛出“无法使用旧的不安全身份验证连接到 MySQL 4.1+"来自 XAMPP 的错误 2022-01-01
- 在SQL中,如何为每个组选择前2行 2021-01-01
- 使用 Oracle PL/SQL developer 生成测试数据 2021-01-01
- SQL 临时表问题 2022-01-01
- 导入具有可变标题的 Excel 文件 2021-01-01