sql - Modify result of a multiple column query with JOIN -


I work with postgresql 9.1 .

I have two linked tables: one table event:

  eventid | Name --------- + ------------ 1 | Event 1 2 | DUCME3 | Triissime 3   

and table images related to events like this:

  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 |   

I want to return a list of all the events with Linked Path and Eltar. So far I have used this query:

  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;   

But there is a problem, this returns:

  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 | |   

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. images> images> images> images, images, images, images, images, images, images, images, images, images, images, images, images . EventId = events.eventId GROUP events.eventId, events.name;

.

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -