Search Postgresql Archives

Re: SELECT statement with sub-queries

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

 



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

Attachment: signature.asc
Description: Digital signature


[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