2012-08-08 38 views
1

我有查询,如:如何使用jooq来表示mysql REGEXP?

SELECT * 
FROM uni_customer 
WHERE mobile REGEXP '^(1[3,4,5,8]){1}\\d{9}$' 

但有像场, REGEXP(String)无此功能和MySQL不支持的语法,如:

SELECT * 
FROM uni_customer 
WHERE regexp(mobile,'^(1[3,4,5,8]){1}\\d{9}$') 

回答

1

官方support for the REGEXP operator不久将在即将推出的jOOQ 2.5.0。与此同时,你可以自己扩展jOOQ,因为这样的:

Condition regexp = Factory.condition("{0} REGEXP {1}", 
            UNI_CUSTOMER.MOBILE, 
            val("^(1[3,4,5,8]){1}\\d{9}$")); 

或者在查询:

create.select() 
     .from(UNI_CUSTOMER) 
     .where(condition("{0} REGEXP {1}", 
         UNI_CUSTOMER.MOBILE, val("^(1[3,4,5,8]){1}\\d{9}$")));