【问题标题】:MySQL Search and Replace In Different FieldsMySQL 在不同字段中的搜索和替换
【发布时间】:2013-01-17 04:59:43
【问题描述】:

您好,我将一堆驾驶游戏导入我的街机网站,但只有一些属于“驾驶”类别。动作和冒险类别中的一些土地是偶然的。我需要在 phpMyAdmin mysql 终端中解决这个问题。我的代码正在尝试在数据库中搜索标签字段中的关键字,并将实体的类别从 Action 或任何可能的内容替换为 Driving

这是我的代码,但似乎不起作用

SELECT * FROM games WHERE tags LIKE '%truck%'
UPDATE games SET category = replace (category, "%", "Driving")
SELECT * FROM games WHERE tags LIKE '%car%'
UPDATE games SET category = replace (category, "%", "Driving")
SELECT * FROM games WHERE tags LIKE '%drive%'
UPDATE games SET category = replace (category, "%", "Driving")
SELECT * FROM games WHERE tags LIKE '%race%'
UPDATE games SET category = replace (category, "%", "Driving")

【问题讨论】:

  • 不确定你想用Replace做什么......虽然

标签: mysql database search replace phpmyadmin


【解决方案1】:

查找标签列包含truckcardriverace 的记录。

Update mytable
SET category = 'Driving'
where tags REGEXP 'truck|car|drive|race'
;

另一个:

Update mytable
SET category = 'Driving'
where tags LIKE '%truck%' 
OR LIKE '%car%' OR LIKE '%drive%' OR LIKE '%race%' 
;
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2023-03-15
  • 1970-01-01
  • 2011-05-09
  • 2011-03-24
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多