Tom Lane writes:
> Exercise for the student: if you need to match a literal backslash
> in a LIKE pattern, how many backslashes do you have to write in your
> query?
I like how Python handles this: You prefix the text literal with an `r'
(as in "raw") and the backslashes are not special. Maybe w
> I wrote:
> > Similarly, '\\%' would be the way to match a literal %. You can
> > actually backslash-quote any single character this way in LIKE,
> > but % and _ are the only ones where it makes a difference.
>
> Er, check that. Backslash itself also needs quoting in LIKE.
>
> Exercise for th
I wrote:
> Similarly, '\\%' would be the way to match a literal %. You can
> actually backslash-quote any single character this way in LIKE,
> but % and _ are the only ones where it makes a difference.
Er, check that. Backslash itself also needs quoting in LIKE.
Exercise for the student: if yo
[EMAIL PROTECTED] writes:
> How do I use LIKE to search for strings with an underscore? The
> documentation (well, Bruce's book) says to use 2 underscores (__) but it
> doesn't work.
If Bruce's book says that, I hope it's not too late for him to change
it ;-)
The correct way is to escape the und
How do I use LIKE to search for strings with an underscore? The
documentation (well, Bruce's book) says to use 2 underscores (__) but it
doesn't work. For example:
create table liketest (
somestr varchar(50)
);
insert into liketest values ('foo_bar');
insert into liketest values ('foobar');