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

From ml@ft-c.de
Subject Re: [GENERAL] SELECT statement with sub-queries
Date
Msg-id 6ca7f542-8add-18e1-3590-49c3ae2a4b22@ft-c.de
Whole thread Raw
In response to [GENERAL] SELECT statement with sub-queries  (Michelle Konzack <linux4michelle@gmail.com>)
Responses Re: [GENERAL] SELECT statement with sub-queries  (ml@ft-c.de)
Re: [GENERAL] SELECT statement with sub-queries  (Michelle Konzack <linux4michelle@gmail.com>)
List pgsql-general
Hallo,

SELECT *
FROM products
WHERE exists
      (SELECT categories.cat FROM categories WHERE
      categories.serial==products.category);
or
SELECT * FROM products
WHERE category IN
       (SELECT categories.cat FROM categories);

On 28.05.2017 19:03, Michelle Konzack 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?
>
>
>
>
>
>
>


pgsql-general by date:

Previous
From: Michelle Konzack
Date:
Subject: Re: [GENERAL] SELECT statement with sub-queries
Next
From: Adrian Klaver
Date:
Subject: Re: [GENERAL] SELECT statement with sub-queries