Changes between Initial Version and Version 1 of Ticket #1435
- Timestamp:
- Apr 9, 2007, 7:23:38 PM (17 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Ticket #1435 – Description
initial v1 1 1 Saw this in my logs: 2 2 {{{ 3 3 Apr 6 16:29:53 ops5 postgres[17289]: [2-1] ERROR: column "topic.subject" must appear in the GROUP BY clause or be used in an aggregate function 4 4 Apr 6 16:29:53 ops5 postgres[17289]: [2-2] STATEMENT: SELECT m.id, m.forum, m.topic, m.time, m.author, m.body, t.subject FROM message m LEFT JOIN (SELECT subject, id FROM 5 5 Apr 6 16:29:53 ops5 postgres[17289]: [2-3] topic GROUP BY id) t ON t.id = m.topic WHERE body LIKE '%subversion%' 6 }}} 6 7 7 8 Appears to be coming from: 8 9 {{{ 9 10 sql = "SELECT m.id, m.forum, m.topic, m.time, m.author, m.body," \ 10 11 " t.subject FROM message m LEFT JOIN (SELECT subject, id FROM" \ 11 12 " topic GROUP BY id) t ON t.id = m.topic WHERE body LIKE '%%%s%%'" \ 12 13 % (query) 14 }}} 13 15 14 16 That subquery is not valid usage of a group by; ie, which subject should it be yielding for each id? Using min() or max() might be a reasonable stop gap. However, AFA Postgres is concerned, I think DISTINCT ON () would be the usual way to go. Of course, I'm not sure of DISTINCT ON's portability(dont use mysql or sqlite).