Мой английский не самый лучший, но я постараюсь. У меня есть таблицы с комментариями и ответами, я хочу выбрать из комментария парентиды LIMIT 10 и выбрать ответы, связанные с ними.
parentid | replyid | commentowner | commentbody | postcreation
------------+-------------+----------------+-----------------------------+----------------------------
h0rfizsUF6 | CGTSh5XLCB | mary@none.com | anyone want to make flowers | 2018-04-30 21:35:53.502332
| CGTSh5XLCB | bob@none.com | reply to mary about flowers | 2018-04-30 21:39:04.313967
| CGTSh5XLCB | mary@none.com | ok well sign up | 2018-04-30 21:39:33.376884
Zasrw8768F | DAeing34355 | james@none.com | Hey everyone! | 2018-04-30 21:40:44.777557
Zasr2222F | DAeingrrrr | mary@none.com | yo yo yo all | 2018-04-30 21:41:33.800034
| CGTSh5XLCB | james@none.com | Im signed up already | 2018-04-30 21:42:03.771954
| DAeingrrrr | jimmy@none.com | in what house | 2018-04-30 21:43:10.992619
(7 rows)
Что я хочу:
parentid | replyid | commentowner | commentbody | postcreation
------------+-------------+----------------+-----------------------------+----------------------------
h0rfizsUF6 | CGTSh5XLCB | mary@none.com | anyone want to make flowers | 2018-04-30 21:35:53.502332
| CGTSh5XLCB | bob@none.com | reply to mary about flowers | 2018-04-30 21:39:04.313967
| CGTSh5XLCB | mary@none.com | ok well sign up | 2018-04-30 21:39:33.376884
| CGTSh5XLCB | james@none.com | Im signed up already | 2018-04-30 21:42:03.771954
Zasr2222F | DAeingrrrr | mary@none.com | yo yo yo all | 2018-04-30 21:41:33.800034
| DAeingrrrr | jimmy@none.com | in what house | 2018-04-30 21:43:10.992619
когда я получаю парентиды, я возвращаюсь с этим
socialnetwork=# select parentid from comments where commentowner ='mary@none.com' and parentid IS NOT NULL;
parentid
------------
h0rfizsUF6
Zasr2222F
но я не могу выполнить forloop через этот возврат.
ERROR: more than one row returned by a subquery used as an expression