postgresql - Trimming parts of a word but each word is different size -
i have table values this:
book;65 book;1000 table;66 restaurant;1202 park;2 park;44444
is there way using postgres sql remove everything, regardless of length of word, includes semi-colon , after it?
i plan on doing query goes after figure out:
select col1, modified_col_1 table_1
--modified without semi-colon , after
you can use substring
, strpos()
this:
select col1, substring(col1, 1, strpos(col1, ';') - 1) modified_col_1
the above give error if there values without ;
another option split string array , pick first element:
select (string_to_array(col1, ';'))[1] table_1
this work if no ;
present
Comments
Post a Comment