I am trying to update my product database and find duplicates after some product numbers where changed.
In the past the changed item numbers just had an extra dash and number or letter on the end and I used this where clause:
where a.ProdNum REGEXP CONCAT('^', b.ProdNum, '(\-|\s)[a-zA-Z0-9]+')
Now the REGEXP is over my head.
Old Product number: BRB-0325
New Product number: 0325-15 (the number after the dash can be any 1 or 2 digit number)
So basically I need a where clause that will drop the “BRB-” from the Old Number and drop any 1 or 2 digit number after the new item number.
I can do the dropping of the “BRB-“, but not sure how to handle dealing with the 1-2 digit number, and I really don’t know how to do both at the same time.
where b.ProdNum = CONCAT('BRB-', c.ProdNum)
Here is what I tried with the 2 digits and that didn’t work.
where c.ProdNum REGEXP CONCAT('^', b.ProdNum, '(\-)[0-9]{1,2}+')
Thanks for your help.
Assuming
c.ProdNumis the new number andb.ProdNumis the old:This adds “BRB-” to the new number and compares it to the old. So you will be essentially comparing “BRB-0325-15” with “BRB-0325-nn”.