From: | Amitabh Kant <amitabhkant(at)gmail(dot)com> |
---|---|
To: | Michelle Konzack <linux4michelle(at)gmail(dot)com> |
Cc: | PGSQL Mailing List <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: SELECT statement with sub-queries |
Date: | 2017-05-28 17:22:48 |
Message-ID: | CAPTAQBLC-imP1PixS0UNAwoOqErzT-svPOcwxHNLE2FnR88M0w@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Sun, May 28, 2017 at 10:33 PM, Michelle Konzack <linux4michelle(at)gmail(dot)com
> wrote:
> Hello *,
>
> I try to get columns from my database with a singel SELECT, but I stuck.
>
> I have 3 tables like:
>
>
> 1) categories (serial,cat)
>
> 2) manufacturers (serial,m_name)
>
> 3) products (serial,category,manufacturer,p_name)
>
>
> where the "category" and "manufacturer"
> are numerical IDs from the two tables above.
>
> So I like to replace the numerical IDs with the appropriated values,
> mean
>
> SELECT * FROM products WHERE category IN
> (SELECT categories.cat FROM categories WHERE
> categories.serial==products.category);
>
> But I get:
>
> ERROR: operator does not exist: integer==integer
> LINE1: ...gories.cat FROM categories WHERE categories.serial==products.
> category);
> ^
> Hmm, "serial" is an "integer" and the "category" and "manufacturer" too.
>
> So whats wrong with it?
>
>
>
>
>
>
>
> --
> Michelle Konzack Miila ITSystems @ TDnet
> GNU/Linux Developer 00372-54541400
>
Wouldn't a simple join like the one below suffice:
Select a.*,b.cat from products as a, categories as b where
a.category=b.serial
or am I missing something?
From | Date | Subject | |
---|---|---|---|
Next Message | Thomas Kellerer | 2017-05-28 17:22:56 | Re: Postgres 10 Beta1 - pg_upgrade fails on Windows 10 |
Previous Message | Michelle Konzack | 2017-05-28 17:03:55 | SELECT statement with sub-queries |