sub-select

Started by Henrik Steffenalmost 23 years ago3 messagesgeneral
Jump to latest
#1Henrik Steffen
steffen@city-map.de

hello,

I am going crazy on this one:

select * from foo where bar like '0101%' and foobar='03997';

works fine (1 result). HOWEVER:

select * from foo where bar like '0101%' and foobar=ANY(SELECT
'03997'::TEXT);

does not work at all (no result)...

shouldn't this work usually???

am i missing something?

thanks anyone

--

Mit freundlichem Gru�

Henrik Steffen
Gesch�ftsf�hrer

top concepts Internetmarketing GmbH
Am Steinkamp 7 - D-21684 Stade - Germany
--------------------------------------------------------
http://www.topconcepts.com Tel. +49 4141 991230
mail: steffen@topconcepts.com Fax. +49 4141 991233
--------------------------------------------------------
24h-Support Hotline: +49 1908 34697 (EUR 1.86/Min,topc)
--------------------------------------------------------
Ihr SMS-Gateway: JETZT NEU unter: http://sms.city-map.de
System-Partner gesucht: http://www.franchise.city-map.de
--------------------------------------------------------
Handelsregister: AG Stade HRB 5811 - UstId: DE 213645563
--------------------------------------------------------

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Henrik Steffen (#1)
Re: sub-select

"Henrik Steffen" <steffen@city-map.de> writes:

select * from foo where bar like '0101%' and foobar='03997';
works fine (1 result). HOWEVER:

select * from foo where bar like '0101%' and foobar=ANY(SELECT
'03997'::TEXT);
does not work at all (no result)...

What's the datatype of foobar? I'm betting it's char(n), and
you're losing in the second case because of (lack of) trailing
spaces.

regards, tom lane

#3Henrik Steffen
steffen@city-map.de
In reply to: Henrik Steffen (#1)
Re: sub-select

thanks tom

stupid me,

--

Mit freundlichem Gru�

Henrik Steffen
Gesch�ftsf�hrer

top concepts Internetmarketing GmbH
Am Steinkamp 7 - D-21684 Stade - Germany
--------------------------------------------------------
http://www.topconcepts.com Tel. +49 4141 991230
mail: steffen@topconcepts.com Fax. +49 4141 991233
--------------------------------------------------------
24h-Support Hotline: +49 1908 34697 (EUR 1.86/Min,topc)
--------------------------------------------------------
Ihr SMS-Gateway: JETZT NEU unter: http://sms.city-map.de
System-Partner gesucht: http://www.franchise.city-map.de
--------------------------------------------------------
Handelsregister: AG Stade HRB 5811 - UstId: DE 213645563
--------------------------------------------------------

----- Original Message -----
From: "Tom Lane" <tgl@sss.pgh.pa.us>
To: "Henrik Steffen" <steffen@city-map.de>
Cc: "pgsql" <pgsql-general@postgresql.org>
Sent: Thursday, May 15, 2003 3:03 PM
Subject: Re: [GENERAL] sub-select

Show quoted text

"Henrik Steffen" <steffen@city-map.de> writes:

select * from foo where bar like '0101%' and foobar='03997';
works fine (1 result). HOWEVER:

select * from foo where bar like '0101%' and foobar=ANY(SELECT
'03997'::TEXT);
does not work at all (no result)...

What's the datatype of foobar? I'm betting it's char(n), and
you're losing in the second case because of (lack of) trailing
spaces.

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org