I’m working on MySQL Workbench 8.0. And I would like to remove all the characters after "-" or "("
Organic Rice Sticks - Spinach OR Organic Rice Sticks (Pack of Three)
To
Organic Rice Sticks
Does MySQL have the functionality to do this?
EDIT: I would also like to remove the characters after "[" such as Organic Rice Sticks [Pack of Three] to Organic Rice Sticks
2
Answers
Though given your sample data, you want to actually remove characters after
' -'
or' ('
. Or remove trailing spaces:Select SUBSTRING(ProductName, 1, LOCATE(‘ ‘, ProductName) – 1) from Products
You can try above here