Re: What is the difference?

From: Richard Huxton <dev(at)archonet(dot)com>
To: Oluwatope Akinniyi <topeakinniyi(at)hotmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: What is the difference?
Date: 2009-03-06 09:08:29
Message-ID: 49B0E80D.4000401@archonet.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Oluwatope Akinniyi wrote:
> This
> SELECT 1 WHERE '95b5a221aeba15c' IN (E'\'' || replace('95b5a221aeba15c+fb4e7219ab898ce+b08586cb81059f9','+',''',''') || E'\'') returns no row while

This returns a string with text '95b...', '...', '...'

> SELECT 1 WHERE '95b5a221aeba15c' IN ('95b5a221aeba15c','fb4e7219ab898ce','b08586cb81059f9') returns a row.

This is three values.

You could either use strpos() on the raw string (as long as you know you
won't get partial/multiple matches). OR split the string to an array:

SELECT 1
WHERE
'95b5a221aeba15c' = ANY(
string_to_array(
'95b5a221aeba15c+fb4e7219ab898ce+b08586cb81059f9',
'+'
)
);

--
Richard Huxton
Archonet Ltd

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Ivan Sergio Borgonovo 2009-03-06 09:31:18 Re: What is the difference?
Previous Message Oluwatope Akinniyi 2009-03-06 09:06:48 Posts not showing