sql - How to delete a common word from large number of datas in a Postgres table -


i have table in postgres. in table more 1000 names there. of names start shri or smt. want delete shrt , smt names , save original name only. how can out database function?

i'll step through logic:

select left(name,3) table 

this select statement bring first 3 chars of column (the 'left' three). if looking smt in first 3 chars, can move statement

 select * table left(name,3) = 'smt' 

now here have few choices can used. i'm going keep left/right style, though replace used. want chars right of smt, don't know how long each string pick out chars. use length() determine that.

select right(name,length(name)-3) table left(name,3) = 'smt' 

i hope syntax right there, i'm lacking postgres environment test it. logic 'all chars on right of string except last 3 (the minus 3 excludes 3 chars on left. change 4 if want last 4 on left)

you can change update statement (set name = right(name,length(name)-3) ) update table, or can use select statement when need name without smt, leave smt in actual data.


Comments

Popular posts from this blog

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

html - How to style widget with post count different than without post count -

url rewriting - How to redirect a http POST with urlrewritefilter -