Re: join with 1 row limit
От | Behringer Behringer |
---|---|
Тема | Re: join with 1 row limit |
Дата | |
Msg-id | 272788.28779.qm@web45203.mail.sp1.yahoo.com обсуждение исходный текст |
Ответ на | Re: join with 1 row limit (Tom Lane <tgl@sss.pgh.pa.us>) |
Список | pgsql-novice |
Sorry for that I just want to get one row from images table for each product row from products table. I tried using a subquery with ROW() it works but all columns are returned as a record and I don't know how to extract thedata as separate columns, this is the closest I got SELECT p.*, (SELECT ROW(id,server_id,format,product_id) FROM products_images pi WHERE pi.product_id = p.id LIMIT 1) AS image FROM products p WHERE p.company = 7 ORDER BY id ASC LIMIT 10 --- On Sat, 1/15/11, Tom Lane <tgl@sss.pgh.pa.us> wrote: > From: Tom Lane <tgl@sss.pgh.pa.us> > Subject: Re: [NOVICE] join with 1 row limit > To: "Behringer Behringer" <behringerdj@yahoo.com> > Cc: pgsql-novice@postgresql.org > Date: Saturday, January 15, 2011, 7:49 AM > Behringer Behringer <behringerdj@yahoo.com> > writes: > > In mysql this query works fine, what is the equivalent > in posgresql? > > SELECT * > > FROM > > products p LEFT JOIN > > products_images pi ON p.id = pi.product_id LIMIT > 1 > > WHERE products.company = 7 > > When asking that sort of question, it would be a good idea > to explain > exactly what you expect that syntax to do. Not all of > us know every > nook and cranny of mysql's nonstandard behaviors. > > > regards, tom lane >
В списке pgsql-novice по дате отправления: