0

一点帮助,我有一个名为 products 的表,其中包含以下字段

[Products]
pid
name
category

问题是在引用同一类别的类别下有很多错误条目。

错误类别的示例:

Bags and wallet
Bags and Wallets
Bag and Walles
Bags & Wallets

正确的应该是包和钱包

我想使用带有子查询的单个 SQL 语句来更改所有内容

UPDATE products
SET category = 'BAGS & WALLETS'
FROM products 
WHERE category = (select category from products WHERE category like 'BAGS AND WALL')
4

2 回答 2

0

你可以实现 MySQL 的REGEXP搜索:

UPDATE products
SET category = 'BAGS & WALLETS'
FROM products 
WHERE category REGEXP 'BAGS? AND WALL'
于 2013-04-18T09:11:46.243 回答
-1

查看该LIKE子句如何使用通配符%

UPDATE products
SET category = 'BAGS & WALLETS'
WHERE UPPER(category) LIKE 'BAGS AND WALL%'
于 2013-04-18T09:08:59.350 回答