question 1

From: ZioBudda <michel(at)michel(dot)enter(dot)it>
To: pgsql-general(at)postgreSQL(dot)org
Subject: question 1
Date: 1998-12-04 18:05:18
Message-ID: Pine.LNX.4.03.9812041904490.456-100000@michel.enter.it
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi, i have this query:
select * from libro where id_libro_key in (select id_libro from
libro_autore where id_auto
re in (select id_autore from autore where ((cognome = 'King' and nome =
'Stephen') OR (cog
nome = 'Clancy' and nome = 'Tom'))))\g
that return me this error:
ERROR: There is no operator '=' for types 'int4' and 'varchar'
You will either have to retype this query using an explicit cast,
or you will have to define the operator using CREATE OPERATOR

but if I split the query in 2 part I obtain:
1)select id_libro from libro_autore where id_autore in (select id_autore
from autore where
((cognome = 'King' and nome = 'Stephen') OR (cognome = 'Clancy' and nome
= 'Tom')))\g
id_libro
--------
11
12
(2 rows)

2)esame=> select * from libro where id_libro_key in ( 11,12)\g
titolo |id_libro|id_utente|collocazione|casa_edit|
data_publ|tipo|difetto|id_libro_ke
y
------------+--------+---------+------------+---------+----------+----+-------+-----------
-
It |d1 | |d1 |apo |05-12-1940| 1|
| 1
1
Il talismano|s1 | |d1 |aop2 |05-12-1985| 1|
| 1
2
(2 rows)

why I can not make the union/join ?
where I'm wrong ?
these are the table:
esame=> \d libro

Table = libro
+----------------------------------+----------------------------------+-------+
| Field | Type |
Length|
+----------------------------------+----------------------------------+-------+
| titolo | varchar() not null |
80 |
| id_libro | varchar() not null |
10 |
| id_utente | int4 |
4 |
| collocazione | varchar() not null |
10 |
| casa_edit | varchar() |
20 |
| data_publ | date |
4 |
| tipo | int4 |
4 |
| difetto | varchar() |
40 |
| id_libro_key | int4 not null default nextval ( |
4 |
+----------------------------------+----------------------------------+-------+

esame=> \d libro_autore

Table = libro_autore
+----------------------------------+----------------------------------+-------+
| Field | Type |
Length|
+----------------------------------+----------------------------------+-------+
| id_libro | varchar() not null |
10 |
| id_autore | int4 not null |
4 |
+----------------------------------+----------------------------------+-------+

"Il divertimento e' giusto se la scimmia ci prende gusto"
--
Italian Linux Press: http://ziobudda.enter.it/ILP/
--
Morelli 'ZioBudda' Davide Michel - Member of Pluto Linux User Group
michel(at)michel(dot)enter(dot)it - http://ziobudda.enter.it/
Linux Problem? Ask to linux(at)media(dot)dsi(dot)unimi(dot)it
"/dev/ziobudda: access to /var/tmp/beer denied, use /var/adm/pineapple"

Browse pgsql-general by date

  From Date Subject
Next Message ZioBudda 1998-12-04 18:05:50 question 2
Previous Message Jackson, DeJuan 1998-12-04 17:53:30 RE: [GENERAL] How can I obtain tables' structure?