Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
基本上,我有一个带有索引 varbinary 字段的表。
我想说:返回 varbinary 字段以(字节数组)开头的所有行。
我如何在 Java 中做到这一点?我有一个带有“SELECT * WHERE data LIKE ?”的 PreparedStatement 但是如果我使用 setBytes 将二进制数组设置为参数,我如何指定 LIKE 查询应该是前缀(而不是另一种类型的正则表达式)?
尽管手册中没有明确说明,但在几个地方暗示 LIKE 在 varbinary 上使用通常的通配符。传递给 setBytes 的二进制数组应在适当的位置包含“%”。
你只需要尝试一下,看看会发生什么。