2012-08-08 35 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}$")));