pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feeddifferent between || and && in a statement
2+ messages / 2 participants
[nested] [flat]
* different between || and && in a statement
@ 1999-10-25 19:43 Christian Guenther <guenther@laokoon.IN-Berlin.DE>
0 siblings, 1 reply; 2+ messages in thread
From: guenther@laokoon.IN-Berlin.DE @ 1999-10-25 19:43 UTC (permalink / raw)
To: pgsql-sql@hub.org
Hi,
I hope theis is the last question for the next time:
1st statement:
SELECT (sum(case when dict.word = 'museum' then 1 else 0 end)
&& sum(case when dict.word = 'immer' then 1 else 0 end)) as qu , dict.url_id
^^ FROM dict, url
WHERE url.rec_id = dict.url_id
AND url.url LIKE '%%'
AND dict.word in ('museum','immer')
GROUP BY dict.url_id
HAVING sum(case when dict.word = 'museum' then 1 else 0 end) &&
sum(case when dict.word = 'immer' then 1 else 0 end) > 0 ^^
The result is:
ERROR: Unable to identify an operator '&&' for types 'int4' and 'int4'
You will have to retype this query using an explicit cast
but if a do it with :
SELECT (sum(case when dict.word = 'museum' then 1 else 0 end)
|| sum(case when dict.word = 'immer' then 1 else 0 end)) as qu , dict.url_id
^^ FROM dict, url
WHERE url.rec_id = dict.url_id
AND url.url LIKE '%%'
AND dict.word in ('museum','immer')
GROUP BY dict.url_id
HAVING sum(case when dict.word = 'museum' then 1 else 0 end) ||
sum(case when dict.word = 'immer' then 1 else 0 end) > 0 ^^
.... all is OK
Whats the different between the logical expression && and || and is there
a way to get && working?
Thanks for any hints. I hope the isn't a stupid question.
Christian
--
Christian Guenther Kunsthistoriker
Fax: +49 030 4464152 E-mail: cg@kunst-und-kultur.de
Tel: +49 030 4442931 http://kunst-und-kultur.de/
Museen, Kuenstler, Ausstellungen, Kunstprojekte ....
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: [SQL] different between || and && in a statement
@ 1999-10-26 14:28 Herouth Maoz <herouth@oumail.openu.ac.il>
parent: Christian Guenther <guenther@laokoon.IN-Berlin.DE>
0 siblings, 0 replies; 2+ messages in thread
From: Herouth Maoz @ 1999-10-26 14:28 UTC (permalink / raw)
To: guenther@laokoon.IN-Berlin.DE; pgsql-sql@hub.org
At 21:43 +0200 on 25/10/1999, Christian Guenther wrote:
> Whats the different between the logical expression && and || and is there
> a way to get && working?
It's really not clear what you are trying to achieve here. Neither || nor
&& are logical operators. In Postgres, || is string concatenation, not
"or". What you would get in sum(...) || sum( ... ) is the concatenation of
the two sums. If one is 32 and the other 17, you'd get 3217.
In any case, what sense does a logical operator have between two integers?
Logical operators should connect between logical operands. But the sums are
sums of integers. There is no such thing as a boolean sum. Unless you meant
to do a cumulative "or" operation between all the rows that have the proper
string value? In that case, you really have to build a custom aggregate for
it.
In any case, in SQL, the word for "or" is... OR. The word for "and" is AND
and the word for "not" is NOT.
Herouth
--
Herouth Maoz, Internet developer.
Open University of Israel - Telem project
http://telem.openu.ac.il/~herutma
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~1999-10-26 14:28 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
1999-10-25 19:43 different between || and && in a statement Christian Guenther <guenther@laokoon.IN-Berlin.DE>
1999-10-26 14:28 ` Herouth Maoz <herouth@oumail.openu.ac.il>
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