| От | Scott Bailey |
|---|---|
| Тема | Re: join from array or cursor |
| Дата | |
| Msg-id | 4A8E298E.1000308@comcast.net обсуждение исходный текст |
| Ответ на | join from array or cursor (John DeSoi <desoi@pgedit.com>) |
| Список | pgsql-general |
John DeSoi wrote: > Suppose I have an integer array (or cursor with one integer column) > which represents primary keys of some table. Is there a simple and > efficient way to return the rows of the table corresponding to the > primary key values and keep them in the same order as the array (or > cursor)? Seems like it should be easy, but I'm not seeing it. > > Thanks, > > > John DeSoi, Ph.D. Matching the rows is easy. Getting them in the same order as the items in the array will require an ORDER BY. The contrib package _int has an idx() that you can use for that. SELECT * FROM foo WHERE foo.id = ANY(myPkArray) ORDER BY idx(myPkArray, id)
В списке pgsql-general по дате отправления:
Сайт использует файлы cookie для корректной работы и повышения удобства. Нажимая кнопку «Принять» или продолжая пользоваться сайтом, вы соглашаетесь на их использование в соответствии с Политикой в отношении обработки cookie ООО «ППГ», в том числе на передачу данных из файлов cookie сторонним статистическим и рекламным службам. Вы можете управлять настройками cookie через параметры вашего браузера