Re: [GENERAL] SELECT statement with sub-queries - Mailing list pgsql-general

From Michelle Konzack
Subject Re: [GENERAL] SELECT statement with sub-queries
Date
Msg-id 20170528185403.GJ3646@cq58.hosts.tdnet.eu
Whole thread Raw
In response to Re: [GENERAL] SELECT statement with sub-queries  (Adrian Klaver <adrian.klaver@aklaver.com>)
Responses Re: [GENERAL] SELECT statement with sub-queries  ("David G. Johnston" <david.g.johnston@gmail.com>)
Re: [GENERAL] SELECT statement with sub-queries  (Adrian Klaver <adrian.klaver@aklaver.com>)
List pgsql-general
On 2017-05-28 11:23:47 Adrian Klaver hacked into the keyboard:
> On 05/28/2017 10:53 AM, Michelle Konzack wrote:
> >>
> >>SELECT * FROM products WHERE category IN
> >>     (SELECT categories.cat FROM categories WHERE
> >>     categories.serial = products.category);

> Because you are comparing categories.cat

ehm no

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"


> which is a varchar to
> products.category which is an integer.  The above is crying out for
> FOREIGN KEYS. For the time being I going to assume products.category
> is a faux FK to categories.serial so;
>
> SELECT * FROM products WHERE products.category = categories.serial;

This is not working


--
Michelle Konzack        Miila ITSystems @ TDnet
GNU/Linux Developer     00372-54541400

Attachment

pgsql-general by date:

Previous
From: ml@ft-c.de
Date:
Subject: Re: [GENERAL] SELECT statement with sub-queries
Next
From: Michelle Konzack
Date:
Subject: Re: [GENERAL] SELECT statement with sub-queries