I have a mysql query in java like
我有一个类似java的mysql查询
public static BusObjectIterator<con.PROJECT_EMP> GetEmpObjectsforOrgandMultipleCategory(String ORG, String CATEGORY)
{
String query=select * from PROJECT_EMP where org = :ORG and category=:CATEGORY;
.....
return ...
}
Here the param ORG will have single value like xyz and CATEGORY String may have multiple values like Cat1,Cat2 etc.., So dynamically i would like to frame query using REGEX to replace the comma separated string values like
在这里,param ORG将有一个值,比如xyz, CATEGORY String可能有多个值,比如Cat1,Cat2等等。,因此,我希望动态地使用REGEX构造查询,以替换逗号分隔的字符串值
select * from PROJECT_EMP where org = 'xyz' and category in ('Cat1','Cat2');
Thanks.
谢谢。
1 个解决方案
#1
3
You can use FIND_IN_SET() function instead of RegEx
可以使用FIND_IN_SET()函数代替RegEx
Try this:
试试这个:
SELECT * FROM PROJECT_EMP WHERE org = :ORG AND FIND_IN_SET(category,:CATEGORY);
#1
3
You can use FIND_IN_SET() function instead of RegEx
可以使用FIND_IN_SET()函数代替RegEx
Try this:
试试这个:
SELECT * FROM PROJECT_EMP WHERE org = :ORG AND FIND_IN_SET(category,:CATEGORY);