Re: Differences in WHERE clause of SELECT - Mailing list pgsql-hackers

From Prabakaran, Vaishnavi
Subject Re: Differences in WHERE clause of SELECT
Date
Msg-id A09FCFD6831B314F9793FEE2D9615B8123BF@ack0102.au.fjanz.com
Whole thread Raw
In response to Re: Differences in WHERE clause of SELECT  (Josh Berkus <josh@agliodbs.com>)
Responses Re: Differences in WHERE clause of SELECT
List pgsql-hackers
Hi Berkus,

Thanks for your time and response.

I do understand that there is no LIKE operator support for integers and it would be great if you could help me
understandthe reason why is it not supported.
 

My intention is to know whether this is not supported because of any technical limitation or is it against any
Postgresql/SQLstandards. 
 

My use cases are like below ones :
Integer LIKE pattern [ESCAPE escape-character] 
1. List all the customers who are having negative balance:
SELECT * from Customer where balance LIKE ‘-%’

2. List all the customers whose id starts with 1:
SELECT * from Customer where cust_id LIKE ‘1%’

Thanks & Regards,
Vaishnavi


-----Original Message-----
From: pgsql-hackers-owner@postgresql.org [mailto:pgsql-hackers-owner@postgresql.org] On Behalf Of Josh Berkus
Sent: Wednesday, 10 July 2013 9:13 AM
To: pgsql-hackers@postgresql.org
Subject: Re: [HACKERS] Differences in WHERE clause of SELECT

Prabakaran,


> I am a newbie to PostgreSQL and was wondering about the following 
> behaviour.

pgsql-hackers is not the appropriate list for this kind of question.  In the future, please post to pgsql-novice,
pgsql-sql,or pgsql-general with this kind of question.  Thanks.
 

> Can you please help me understand why 'LIKE' does not use implicit 
> cast ?

Like uses the operator class "text_pattern_ops" which doesn't include an implict cast.  For one thing, the implicit
castis from text --> integer, not the other way around, and there is no LIKE operator for integers.
 

--
Josh Berkus
PostgreSQL Experts Inc.
http://pgexperts.com


-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers


pgsql-hackers by date:

Previous
From: Troels Nielsen
Date:
Subject: Re: SSL renegotiation
Next
From: Jaime Casanova
Date:
Subject: Re: Differences in WHERE clause of SELECT