Re: [GENERAL] SELECT statement with sub-queries

Поиск
Список
Период
Сортировка
От David G. Johnston
Тема Re: [GENERAL] SELECT statement with sub-queries
Дата
Msg-id CAKFQuwar_X8crrfeiCxva-zbUvBrNbN-YTT2Jkm1wMuh3ZskCg@mail.gmail.com
обсуждение исходный текст
Ответ на Re: [GENERAL] SELECT statement with sub-queries  (Michelle Konzack <linux4michelle@gmail.com>)
Список pgsql-general
On Sun, May 28, 2017 at 11:54 AM, Michelle Konzack <linux4michelle@gmail.com> wrote:

I want to replace in the output the numerical ID from "products.category"
with the value of "categories.cat", where the "products.category" match
the "categories.serial"

​Then go and read the first response in this thread, ​Amitabh Kant's, and confirm it works or say why it does not.  Personally I prefer "products JOIN categories ON/USING" but that is style and the "FROM products, categories WHERE" formulation will give the correct answer.

The syntax error in your original message is, like others have said, because "==(int, int)" is not a known operator.

And typically one writes:  "EXISTS (correlated subquery)" instead of "IN (correlated subquery)".  But if you want to replace a column in the output a predicate subquery (WHERE clause) that effectively implements a semi-join (only return results from one table) will not help you since you cannot actually refer to any of the columns in the subquery in the main query.  You need an actual join to do that.  IOW, writing "FROM products WHERE" when the output value you want is on the category table isn't going to help you.

David J.

В списке pgsql-general по дате отправления:

Предыдущее
От: Neil Anderson
Дата:
Сообщение: Re: [GENERAL] Help with terminology to describe what my software does please?
Следующее
От: Adrian Klaver
Дата:
Сообщение: Re: [GENERAL] SELECT statement with sub-queries