在我的存储库中,我有以下内容
public interface TenantRepository extends JpaRepository<Tenant, UUID> {
...
@Query("select substring(email from '@(.*)$') as domain from Tenant group by domain")
public List<String> findAllDomain();
}
当我试图执行它时,我得到一个错误,它说:
Syntax error in SQL statement "select substring(tenant0_.email, [*]from, '@(.*)ParseError: KaTeX parse error: Can't use function '\)' in math mode at position 2: '\̲)̲ as c…') as col_0_0_ from tenants tenant0_ group by col_0_0_
因此,我将查询更改为:
"select substring(email from '@(.*)\\$') as domain from Tenant group by domain"
但它得到了另一个错误:
org.h2.jdbc.JdbcSQLSyntaxErrorException: Syntax error in SQL statement "select substring(tenant0_.email, [*]from, '@(.*)\\$') as col_0_0_ from tenants tenant0_ group by col_0_0_"; expected "INTERSECTS (, NOT, EXISTS, UNIQUE, INTERSECTS"; SQL statement:
select substring(tenant0_.email, from, '@(.*)\$') as col_0_0_ from tenants tenant0_ group by col_0_0_
当我在我的PgAdmin4上尝试查询时,它工作了。
有什么建议吗?
谢谢。
1条答案
按热度按时间yxyvkwin1#
我假设您正在尝试获取所有的电子邮件域。
数据库中的电子邮件
查询响应