Обсуждение: update problem

Поиск
Список
Период
Сортировка

update problem

От
Paul Alarcon
Дата:
hello in using postgres 8.3 on windows and i have aproblem to update a table, this is the facts, I have a tables where i want to update the name based on a lenght of a field for instance i want to update all the rows where the the substring(cuenta from 17 for 40) is equal around all the table may you have an idea how i could made it
thanks a lot


Get news, entertainment and everything you care about at Live.com. Check it out!

Re: update problem

От
"A. Kretschmer"
Дата:
In response to Paul Alarcon :
> hello in using postgres 8.3 on windows and i have aproblem to update a table,
> this is the facts, I have a tables where i want to update the name based on a
> lenght of a field for instance i want to update all the rows where the the
> substring(cuenta from 17 for 40) is equal around all the table may you have an
> idea how i could made it
> thanks a lot

I'm not sure if i understand you, but how about

test=*# select * from foobar;
 id |   name
----+-----------
  1 | 123
  2 | 123abc123
  3 | 234abc234
  4 | 345abc345
  5 | 123456789
(5 rows)

-- change all the trings contains substring 'abc' from 4-6 position to
-- 'hit'

test=*# update foobar set name='hit' where substr(name, 4, 3)='abc';
UPDATE 3
test=*# select * from foobar;
 id |   name
----+-----------
  1 | 123
  5 | 123456789
  2 | hit
  3 | hit
  4 | hit
(5 rows)


HTH, Andreas
--
Andreas Kretschmer
Kontakt:  Heynitz: 035242/47150,   D1: 0160/7141639 (mehr: -> Header)
GnuPG-ID:   0x3FFF606C, privat 0x7F4584DA   http://wwwkeys.de.pgp.net