Re: update problem

Поиск
Список
Период
Сортировка
От A. Kretschmer
Тема Re: update problem
Дата
Msg-id 20090514051902.GA25647@a-kretschmer.de
обсуждение исходный текст
Ответ на update problem  (Paul Alarcon <paul_pag00@hotmail.com>)
Список pgsql-novice
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

В списке pgsql-novice по дате отправления:

Предыдущее
От: "Ridvan Lakas ng Bayan S. Baluyos"
Дата:
Сообщение: Re: tablespace question
Следующее
От: Ilya Urikh
Дата:
Сообщение: Re: C-Language function invocation from another one.