Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

The only difference between like and similar to is to pattern matches the given string. It is similar to LIKE, except that it interprets the pattern using the SQL standard's definition of a regular expression

...

  • | denotes alternation (either of two alternatives).

  • * denotes repetition of the previous item zero or more times.

  • + denotes repetition of the previous item one or more times.

  • ? denotes repetition of the previous item zero or one time.

  • {m} denotes repetition of the previous item exactly m times.

  • {m,} denotes repetition of the previous item m or more times.

  • {m,n} denotes repetition of the previous item at least m and not more than n times.

  • Parentheses () can be used to group items into a single logical item.

  • A bracket expression [...] specifies a character class, just as in POSIX regular expressions.

#

Query

Output

1cpsdb=# SELECT * FROM FRAGMENT WHERE anchor_id = 3 and attributes->>'pub_year'similar to '%(94|95)%';

{
 "lang": "en", 
 "price": 699, 
 "title": "The Golden Compass", 
 "authors": [
           "Philip Pullman"
 ], 
"pub_year":1995
}                                                                                               
{
 "lang": "english", 
 "price": 895, 
 "title": "Feersum Endjinn", 
 "authors": [
            "Iain M. Banks"
 ], 
"pub_year":1994
}              

Performance wise : As we are not making much changes for query , the performance of contains will work same as the existing query.