1
0
mirror of https://github.com/jbranchaud/til synced 2026-01-05 08:08:02 +00:00

Add Set Inclusion With hstore as a postgres til.

This commit is contained in:
jbranchaud
2015-12-24 11:56:15 -06:00
parent 660782e55e
commit 306a92036a
2 changed files with 23 additions and 0 deletions

View File

@@ -0,0 +1,22 @@
# Set Inclusion With hstore
In PostgreSQL, `hstore` records can be compared via set inclusion. The `@>`
and `<@` operators can be used for this. The `@>` operator checks if the
right operand is a subset of the left operand. The `<@` operator checks if
the left operand is a subset of the right operand.
```sql
> select '"one"=>"1", "two"=>"2", "three"=>"3"'::hstore @> '"two"=>"2"'::hstore;
?column?
----------
t
> select '"one"=>"1", "two"=>"2", "three"=>"3"'::hstore <@ '"two"=>"2"'::hstore;
?column?
----------
f
```
See the [`hstore` PostgreSQL
docs](http://www.postgresql.org/docs/current/static/hstore.html) for more
details.