Re: SELECT statement with sub-queries

From: Michelle Konzack <linux4michelle(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: SELECT statement with sub-queries
Date: 2017-05-28 17:53:46
Message-ID: 20170528175346.GI3646@cq58.hosts.tdnet.eu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 2017-05-29 03:24:54 rob stone hacked into the keyboard:
> You only need a single equals sign in SQL.
>
> SELECT * FROM products WHERE category IN 
>     (SELECT categories.cat FROM categories WHERE 
>     categories.serial = products.category);

I have tried this too, but then I get:

ERROR:  operator does not exist: integer = character varying
LINE 1: SELECT * FROM products WHERE category IN (SELECT categories....
^

My sql file is:

----8<------------------------------------------------------------------
DROP TABLE categories;
DROP TABLE manufacturers;
DROP TABLE products;

CREATE TABLE categories (
serial integer NOT NULL,
cat varchar(40),
);

CREATE TABLE manufacturers (
serial integer NOT NULL,
m_name varchar(40),
m_address varchar(200),
m_images varchar(100),
m_desc varchar(1000),
);

CREATE TABLE products (
serial integer NOT NULL,
category integer NOT NULL,
manufacturer integer NOT NULL,
p_name varchar(40),
p_images varchar(100),
p_desc varchar(10000),
);
----8<------------------------------------------------------------------

This is WHY I am puzzeling arround with the "integer" error.

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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message ml 2017-05-28 18:19:59 Re: SELECT statement with sub-queries
Previous Message rob stone 2017-05-28 17:24:54 Re: SELECT statement with sub-queries