Обсуждение: Replacing "LIKE" with "="

Поиск
Список
Период
Сортировка

Replacing "LIKE" with "="

От
sharmad@goatelecom.com
Дата:
Can I replace a query statement having a "LIKE" with a statement having "="
still getting the same functionality

Like for ex:-
SELECT * from teble_name WHERE name LIKE "%name%";

Keeping in mind the output of the query i want to replace this query with a
statement having "=" and no more "LIKE"

TIA
-Sharmad


Re: Replacing "LIKE" with "="

От
"Josh Berkus"
Дата:
Sharmad,

> Can I replace a query statement having a "LIKE" with a statement
> having "="
> still getting the same functionality
> 
> Like for ex:-
> SELECT * from teble_name WHERE name LIKE "%name%";

You cannot.  

WIthin the SQL standard, you must use "LIKE" if you want to use
wildcards.  PostgreSQL also supports the Regular Expression operator "~"
which does a different kind of pattern matching.  See "Functions and
Operators" in the online PostgreSQL documentation, or purchase a copy of
"PostgreSQL: Introduction and Concepts".

-Josh Berkus


______AGLIO DATABASE SOLUTIONS___________________________                                      Josh Berkus Complete
informationtechnology      josh@agliodbs.com  and data management solutions       (415) 565-7293 for law firms, small
businesses       fax 621-2533   and non-profit organizations.      San Francisco