From: Nicolas Caillaud <Nicolas.Caillaud@mail.dotcom.fr>
To: pgsql-sql@postgresql.org
Subject: getting the values of a complex attribute
Date: Mon, 08 Jun 1998 00:05:23 +0200
Message-ID: <357B0EA3.F0A1E65F@mail.dotcom.fr> (raw)
Hi *
I'm new to SQL, and being in the Linux world, I began with Postgresql.
One day, I wrote the following :
- create table person (name text);
- create table book(name text, author person);
simple, isn't it ? ;()
Now :
- insert into person (name) values ('nicolas');
INSERT 691704 1
- insert into person (name) values ('julien');
INSERT 691705 1
now, to fill book :
- insert into book (name, author) values ('my book', 691704);
INSERT 691706 1
ok, but cant i write anything but the oid of the person record i want to
insert ? (this is my first question)
Next :
insert into book (name,author) values ('other ', 691705);
INSERT 691707
OK, right now, i want te get all books written by 'nicolas', i want to write
select * from book where author.name = 'nicolas';
ERROR: author: Table does not exist.
select * from book where author = 691706;
ERROR: There is no operator '=' for types 'person' and 'int4'
You will either have to retype this query using an explicit cast,
or you will have to define the operator using CREATE OPERATOR
Now my second question : what can i do to get (in a simpler manner) all the books written by 'nicolas' ?
I think that writing an operator just to do that is a little bit complicated :-((
Thank you if someone got the answer .......
--
Nicolas Caillaud
Nicolas.Caillaud@mail.dotcom.fr
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-sql@postgresql.org
Cc: Nicolas.Caillaud@mail.dotcom.fr
Subject: Re: getting the values of a complex attribute
In-Reply-To: <357B0EA3.F0A1E65F@mail.dotcom.fr>
References: <357B0EA3.F0A1E65F@mail.dotcom.fr>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox