| From: | Richard Huxton <dev(at)archonet(dot)com> |
|---|---|
| To: | rupesh bajaj <rupesh(dot)bajaj(at)gmail(dot)com> |
| Cc: | pgsql-general(at)postgresql(dot)org |
| Subject: | Re: Like operator |
| Date: | 2007-06-06 14:10:22 |
| Message-ID: | 4666C04E.5070807@archonet.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-general |
rupesh bajaj wrote:
> Hi,
> Is Like operator can be used to join two relation. If yes what is its use?
> And how it is used?
It tests a column for a partial match. So:
'abc' LIKE 'a%' = true
'abc' LIKE 'a_c' = true
'abc' LIKE 'A%' = false
See the manuals for details on other wildcard options and alternative
pattern-matching systems.
You can store the pattern in a column too, though that's less common:
richardh=> SELECT * FROM targets;
tgt
-----------
abc123def
ghi123def
(2 rows)
richardh=> SELECT * FROM patterns;
patt
-------
abc%
%123%
(2 rows)
richardh=> SELECT tgt,count(*) FROM targets, patterns
WHERE tgt LIKE patt GROUP BY tgt ORDER BY tgt;
tgt | count
-----------+-------
abc123def | 2
ghi123def | 1
(2 rows)
HTH
--
Richard Huxton
Archonet Ltd
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Siva | 2007-06-06 14:54:29 | Re: New Live CD needed |
| Previous Message | Richard Huxton | 2007-06-06 14:04:42 | Re: plperl and/or insert trigger problem |