且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

从mysql中的字段中删除重复的单词

更新时间:2023-01-20 16:22:16

您描述的模型(所有标签放入单个单元格,以空格分隔)未标准化,因此您无法期望找到简单,高效且可靠的模型从数据库服务器处理数据的方法(除了阅读专栏之外).到目前为止,PHP是您计划进行清理的唯一机会,而且您必须检索每一行.

The model you describe (all tags into a single cell, separated by spaces) is not normalized so you can't expect to find a simple, performant and reliable way to do stuff with it from the database server (beyond reading the column). The way it's now, PHP is your only chance to do the cleanup you are planning to do, and you'll have to retrieve every row.

现在对数据库设计进行一些更改是否为时已晚?如果将每个标签存储在tag表的单独一行中,则可以使用普通SQL进行很多操作.

Is it too late to make a little change in the database design? If you store each tag into a separate row in a tag table you'd be able to do lots of stuff from plain SQL.