Re: [SQL] Search for underscore w/ LIKE

2000-07-07 Thread Peter Eisentraut
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

Re: [SQL] Search for underscore w/ LIKE

2000-07-07 Thread Bruce Momjian
> 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

Re: [SQL] Search for underscore w/ LIKE

2000-07-07 Thread Tom Lane
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

Re: [SQL] Search for underscore w/ LIKE

2000-07-07 Thread Tom Lane
[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

[SQL] Search for underscore w/ LIKE

2000-07-07 Thread brianb-pgsql
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');