sql - Modify result of a multiple column query with JOIN -
I work with I have two linked tables: one table event: and table images related to events like this: I want to return a list of all the events with Linked Path and Eltar. So far I have used this query: But there is a problem, this returns: As you can see the path and altas are not in the same order and for this moment there is no way to know which things and paths are similar to the same image. So my question is: In what way is there a way to group them or if this is not possible, how can I provide it in that order? Thank you;) I find simple modification - if you do not want to see results on different lines - Only comma, url, alt, url, alt, ... will have to work differently for a different job on a different URL / ALT pair for a comma. . postgresql 9.1 .
eventid | Name --------- + ------------ 1 | Event 1 2 | DUCME3 | Triissime 3
id | Path | Alt | Eventum | ---- + ------------------------ + ------ + --------- + 1 | /something/to/img.jpg | Alt | 1 | 2 | /something/to/img2.jpg | Alt2 | 1 | 3 | /something/to/img3.jpg | Alt3 | 2 |
SELECT events.eventId, events.name, string_agg (different images, ',') AS path, string_agg (different images, '' , ') Ats At Its Events Byte Join Image In Images.Anvent Id = Events.Event Import Group In Events.EventIdid;
eventid | Name | Path | Alts --------- + ------------ + -------------------------- -------------------- + ---------- 1 | Event 1 | /something/to/img2.jpg,/something/to/img.jpg | Alt, alt2 2 | DUCME | /something/to/img3.jpg | Alt3 3 | Triissime 3 | |
Comments
Post a Comment