[{"互联网":["网络媒体","微博","墨迹天气","河北天气","其他"]},{"气象部门":["灾害大典","灾情普查","灾情直报","其他"]}]
**.java文件
1 if(StringUtil.isNotEmpty(dataSource)){ 2 if(dataSource.equals("互联网")){ 3 sql_dataSource = " AND 数据来源 = '互联网' "; 4 if(StringUtil.isNotEmpty(infoSource)){ 5 //infoSource = infoSource.replaceAll(" +", ""); //去除字符串空格 6 if(infoSource.equals("其他")){ 7 //like 模糊查询 8 sql_infoSource = " AND 信息来源 not like '网络媒体' and 信息来源 not like '%微博%' and 信息来源 not like '墨迹天气' and 信息来源 not like '河北天气' "; 9 } else{ 10 sql_infoSource = " AND 信息来源 like '%"+ infoSource +"%' "; 11 } 12 } 13 }else if(dataSource.equals("气象部门")){ 14 sql_dataSource = " AND 数据来源 = '气象部门' "; 15 if(StringUtil.isNotEmpty(infoSource)){ 16 if(infoSource.equals("其他")){ 17 //in 18 sql_infoSource = " AND 信息来源 not in "+ "("+"'灾害大典'"+","+"'灾情直报'"+","+"'灾情普查'"+") "; 19 }else{ 20 sql_infoSource = " AND 信息来源 = '" + infoSource +"' "; 21 } 22 } 23 }else{ 24 sql_dataSource = " AND 数据来源 = '" + dataSource +"' "; 25 if(StringUtil.isNotEmpty(infoSource)){ 26 sql_infoSource = " AND 信息来源 = '" + infoSource +"' "; 27 } 28 } 29 }
参考:
SQL模糊查询条件的四种匹配模式https://www.cnblogs.com/LoveSuk/p/6672768.html