Remove specific row from multiple rows of database in SQL
I have a column that contains the page titles that have the website name appended to the end of each one. (for example, product name | company name). I would like to remove "| Company Name Inc." from several lines at the same time. Which SQl query commands (or the query itself) will allow me to accomplish this?
To re-illustrate, I want to convert multiple 1 column rows from this: Product Name | Company name Inc.
For this: Product name
+2
a source to share
1 answer
You mean something like (in SQL Server):
Update Table
Set PageTitle = Substring( PageTitle, 1, CharIndex( '|', PageTitle ) - 1)
Basically, I use CharIndex to find the delimiter ('|') and then using a substring to find everything just before the delimiter.
In MySql, I believe it would look like this:
Update Table
Set PageTitle = Substring( PageTitle, 1, Substring_Index(PageTitle, '|' ) - 1)
+1
a source to share