0
  • I have a Column Line_num

Line_Num

06-ZB-A23-475004-SHT1

10-ZB-A23-4750041-SHT2

2.5-ZB-A23-4750-SHT3

06-ZB-A23-475004-5H6-SHT13

  • Result I want is

Line_Num

06-ZB-A23-475004

10-ZB-A23-4750041

2.5-ZB-A23-4750

06-ZB-A23-475004-5H6

I have used the below Code

UPDATE Filename SET line_num = REPLACE(line_num, '-SHT*', '') WHERE line_num like '%-SHT%';

But it does not work. can anyone help me with this.

UPDATE Filename SET line_num = REPLACE(line_num, '-SHT*', '') WHERE line_num like '%-SHT%';

Sudhir S
  • 1
  • 1
  • * in replace just says replace * and not all characters after T. You should use a regular expression. Maybe this post can help you : https://stackoverflow.com/questions/38877856/replace-a-part-of-a-string-with-regexp-in-sqlite3 . It seems there is actually no other way. – Shim-Sao Dec 24 '18 at 13:00

1 Answers1

0

Try below query

UPDATE Filename SET line_num = substr(line_num, 1, instr(line_num, '-SHT')-1) WHERE line_num like '%-SHT%';
Milad Aghamohammadi
  • 1,866
  • 1
  • 16
  • 29