Re: switching from mysql
От | Brad Hilton |
---|---|
Тема | Re: switching from mysql |
Дата | |
Msg-id | 1005929727.29326.0.camel@aragorn обсуждение исходный текст |
Ответ на | Re: switching from mysql (Tom Lane <tgl@sss.pgh.pa.us>) |
Ответы |
Re: switching from mysql
Re: switching from mysql |
Список | pgsql-novice |
On Thu, 2001-11-15 at 22:16, Tom Lane wrote: > Brad Hilton <bhilton@vpop.net> writes: > > I issue > > select * from items GROUP BY id > > I get: > > "Attribute items.name must be GROUPed or used in an aggregate function" > > It appears in MySQL if you group on a unique key, then you aren't > > required to group on the rest of the fields you select from the table. > > If you know it's a unique key, why are you bothering to GROUP? > If it's not a unique key, then there's no unique value for the other > columns. Either way, I can see no sense to this query. The SQL92 > spec doesn't see any sense in it either. The example I gave was a simple one to demonstrate my problem. Let me give a better example. Let's say I have 3 tables: items, stores, and store_items. 'store_items' maps items to stores. If I want to select all items that are in at least one store, I currently do: select items.* from items, store_items where items.id = store_items.item_id group by items.id Is there a better way to do this query? > I believe MySQL thinks that this query means > > ... FROM (a CROSS JOIN b) LEFT JOIN c ON condition > > which unfortunately for them is not what the SQL spec says the > syntax means. The spec's interpretation is > > ... FROM a CROSS JOIN (b LEFT JOIN c ON condition) > Thank you for your help! -Brad
В списке pgsql-novice по дате отправления: