Can I use LIKE to achieve the following result

Started by Yan Cheng Cheokabout 16 years ago3 messagesgeneral
Jump to latest
#1Yan Cheng Cheok
yccheok@yahoo.com

I have the following original table :

ID | Item
=========
0 | Car1
1 | Car2
2 | Car3
3 | Cat1
4 | Cat2
5 | Cat3

I would like to return setof record, with the following :

ID | Item
=========
0 | Car1
1 | Car2
2 | Car3
3 | Cat

Is it possible to achieve using LIKE command?

Thanks and Regards
Yan Cheng CHEOK

#2Harry McCarney
HMcCarney@DialecticIT.com
In reply to: Yan Cheng Cheok (#1)
Re: Can I use LIKE to achieve the following result

Something like this will be possible but your data sets are contradictory.
There is no
3 | Cat
Row in the original table..

-----Original Message-----
From: pgsql-general-owner@postgresql.org
[mailto:pgsql-general-owner@postgresql.org] On Behalf Of Yan Cheng Cheok
Sent: 20 January 2010 18:23
To: pgsql-general@postgresql.org
Subject: [GENERAL] Can I use LIKE to achieve the following result

I have the following original table :

ID | Item
=========
0 | Car1
1 | Car2
2 | Car3
3 | Cat1
4 | Cat2
5 | Cat3

I would like to return setof record, with the following :

ID | Item
=========
0 | Car1
1 | Car2
2 | Car3
3 | Cat

Is it possible to achieve using LIKE command?

Thanks and Regards
Yan Cheng CHEOK

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

#3Ricardo Ramírez
ricardojfr@gmail.com
In reply to: Harry McCarney (#2)
Re: Can I use LIKE to achieve the following result

Hi.
You can return a set of record of that table with a sentence including the
LIKE operator, i.e.

SELECT ID, Item FROM your_table WHERE item LIKE 'Car_';

and you would get this result:

ID | Item
=========
0 | Car1
1 | Car2
2 | Car3

Take a look of the documentation in the postgresql documentation for pattern
matching:
http://www.postgresql.org/docs/8.3/interactive/functions-matching.html

greets.
Ricardo Ramirez

2010/1/20 Harry McCarney <HMcCarney@dialecticit.com>

Show quoted text

Something like this will be possible but your data sets are contradictory.
There is no
3 | Cat
Row in the original table..

-----Original Message-----
From: pgsql-general-owner@postgresql.org
[mailto:pgsql-general-owner@postgresql.org] On Behalf Of Yan Cheng Cheok
Sent: 20 January 2010 18:23
To: pgsql-general@postgresql.org
Subject: [GENERAL] Can I use LIKE to achieve the following result

I have the following original table :

ID | Item
=========
0 | Car1
1 | Car2
2 | Car3
3 | Cat1
4 | Cat2
5 | Cat3

I would like to return setof record, with the following :

ID | Item
=========
0 | Car1
1 | Car2
2 | Car3
3 | Cat

Is it possible to achieve using LIKE command?

Thanks and Regards
Yan Cheng CHEOK

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

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