0

I have this and it works brilliantly

    `PD`.`Salesforce Account ID` AS Account_ID,
    `PD`.`Company Product Salesforce ID` AS Product_ID,
    `PD`.`Salesforce Account Name` AS Account_Name,
    `PD`.`Company Product Name` AS Product_Name
FROM
    `Product Details` AS `PD`
        INNER JOIN
    `Product Standards` AS `PS` ON (`PD`.`Company Product Salesforce ID` = `PS`.`Company Product Salesforce ID`)
WHERE
    `PD`.`Publish to Website` = '1'
        AND `PD`.`Record Type Name` = 'SBD'
        AND `PD`.`Product Category` = 'Doors'
        AND `PD`.`Product Type` REGEXP '[[:<:]]Automatic Sliding powered[[:>:]]'
GROUP BY `Account_Name`
ORDER BY Account_Name ASC

But it all goes wrong when the text to match has brackets like this

REGEXP'[[:<:]]Automatic Sliding (powered)[[:>:]]'

I have tried escaping with \ and \ but without success. I need the word boundary. Does anyone know how to escape the brackets in MySQL regexp

nbk
  • 45,398
  • 8
  • 30
  • 47
Phil
  • 37
  • 4
  • https://stackoverflow.com/help/minimal-reproducible-example – Shoaeb May 19 '20 at 22:19
  • 1
    Use `REGEXP '[[:<:]]Automatic Sliding \\(powered\\)'`. 1) `)` is a special char and must be escaped, 2) there is no closing word boundary between `)` and next char because `)` is not a word char. – Wiktor Stribiżew May 19 '20 at 22:20
  • I had tried double slash but its the fact that its a non-word boundary at the end that must be doing it. As the area in the regexp is filled by a variable and I need to have the word boundary for 99% of the strings that will be there I need to find a way that if a string has ( ) it will work but thank you for highlighting why this is not working. Much appreciated – Phil May 20 '20 at 07:03
  • MySQL 8.0 needs `\b` for "word boundary". – Rick James May 24 '20 at 20:36

0 Answers0