Skip site navigation (1) Skip section navigation (2)

Re: update

From: denis(at)coralindia(dot)com
To: "cristi" <cristi(at)dmhi(dot)ct(dot)ro>, <pgsql-novice(at)postgresql(dot)org>
Subject: Re: update
Date: 2002-02-27 05:36:52
Message-ID: 007601c1bf50$c36130a0$0232a8c0@coralindia.com (view raw or flat)
Thread:
Lists: pgsql-novice
TRy

update my_table set codlm='22'||substring(codlm,3) where substr(codlm,1,2) = '45'

HTH

Denis

  ----- Original Message ----- 
  From: cristi 
  To: pgsql-novice(at)postgresql(dot)org 
  Sent: Tuesday, February 26, 2002 12:13 PM
  Subject: [NOVICE] update


  I have a table (my_table) with this structure:
  codlm varchar(7)

  The records are:
  45122AD
  45122AD
  45123AC
  440331B
  430332C
  440222X

  I want to change the first 2 letters from 45 to 22 something like this:

  22122AD
  22122AD
  22123AC
  440331B
  430332C
  440222X

  I tried:
  update my_table set codlm='22'||substring(codlm,2) where codlm like '45'

  but the result is:

   225
   225
   225
   440331B
   430332C
   440222X

  Where is the mistake?

  Thanks!

In response to

  • update at 2002-02-26 06:43:14 from cristi

pgsql-novice by date

Next:From: cristi69Date: 2002-02-27 06:17:05
Subject: Re: update
Previous:From: Josh BerkusDate: 2002-02-27 00:34:01
Subject: Re: Major newbie - Part deux

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group