Reputation: 177
I am trying to update my product database and find duplicates after some product numbers were simplified.
Here is what I am trying that is not working:
SELECT b.Id as OLDID, c.Id as NEWID
FROM productdata b, productdata c
WHERE b.ProdNum REGEXP CONCAT('^', c.ProdNum, '(\-|\s)[a-zA-Z0-9]+(\-|\s)[a-zA-Z0-9]+')
Old Product number: WR-101 3 Day (as well as WR-101 1 Day, etc.)
New Product number: WR-101
So basically I need a where clause that will match up the new Product number with the old product number that had "1 Day", "3 Day" etc. on them.
Thanks for your help.
Upvotes: 2
Views: 147
Reputation: 191789
MySQL's regex flavor does not support \s
for spaces. You need to use [[:space:]]
. You also don't need to escape the dash:
(-|[[:space:]])[a-zA-Z0-9]+(-|[[:space:]])[a-zA-Z0-9]+
Upvotes: 3