jul
jul

Reputation: 507

MySQL, remove partial data from a field

I have a table with a MEDIUMTEXT column. Many records contain a value in that field with a value like "WordA WordB || RandomWords" i would like to remove " || RandomWords" so the value will be "WordA WordB". How can I do that? In other words I need to search for the "||" characters and delete all that comes after.

Upvotes: 1

Views: 57

Answers (1)

Mihai
Mihai

Reputation: 26784

UPDATE t SET col=SUBSTRING_INDEX(col,'||',1)

Assuming a single || per row

Upvotes: 2

Related Questions