给出一个像这样的表格:
id | value ------------------- 1 | food 2 | foot 3 | barfoo 4 | bar 5 | baz
使用postgres我想从搜索字段的开头找到值字段匹配的所有行.有点像SELECT * FROM table where 'foo' ilike value%
搜索'foo'会返回食物和脚,但不会返回barfoo.
我认为这应该很容易,但我遗漏了一些明显的东西.
不应该切换比较吗
where value ilike 'foo%'
Run Code Online (Sandbox Code Playgroud)
编辑
SQL 方言如此之多,灰质存储空间却如此之少。