Search Postgresql Archives

Re: SELECT statement with sub-queries

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sun, May 28, 2017 at 11:54 AM, Michelle Konzack <linux4michelle@xxxxxxxxx> 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.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]

  Powered by Linux