Search code examples
sqlstringtrim

How to trim strings in database?


I have a database table (named firsttable )with words and scores like this

words     score
book's      2
book        5
pen         4
bag         6
books       7

What I want to do is, since book is root for book's and books I would like to delete book's and books from table and add their score on word book.However for words like copy-copies-copy's it wont work.but it doesnt matter. and at the end I would like to have database table like this

words     score

book        14
pen         4
bag         6

Is it possible*


Solution

  • use a wildcard % for the suffix to the word book. Something like...

    SELECT score FROM MyTable where words LIKE book%