mysql IF语句,模糊检索

devtools/2024/10/18 14:25:44/
  • 使用MySQL IF语句完成条件检索
    IF(expr1,expr2,expr3),expr1如果满足条件就用expr2,否则用expr3
sql">SELECTa.*,count(*) AS stdSum 
FROMidb_std_power_engin_v1 a 
WHERE1 = 1 AND (IF( 'KV' IS NOT NULL, a.NAME REGEXP 'KV', 1 = 1 ) ORIF( 'KV' IS NOT NULL, a.description REGEXP 'KV', 1 = 1 ) ) 
AND
IF( 138 IS NOT NULL, a.country = 138, 1 = 1 ) 
GROUP BY
NAME LIMIT 0,10

REGEXP 正则表达式,用于模糊匹配多个数据

/*** @description: 中英互换 正则表达查询* @author csb* @date: 2022/12/29 11:24*/public static String suggestTermNameByRegular(String keyword,List<String> termName) {StringBuffer keywords = new StringBuffer();keywords.append(keyword+"|");if(null != termName && termName.size() > 0){termName.stream().forEach(a -> {keywords.append(a+'|');});}//去除最后的 |keywords.deleteCharAt(keywords.length() - 1);return String.valueOf(keywords);}
/*** @description: 关键字高亮* @author csb* @date: 2022/12/23 10:48*/public static String IgnoreCaseReplace(String source, String patternstring) {Pattern p = Pattern.compile(patternstring, Pattern.CASE_INSENSITIVE);Matcher mc = p.matcher(source);StringBuffer sb = new StringBuffer();while (mc.find()) {mc.appendReplacement(sb, "<em>" + mc.group() + "</em>");}mc.appendTail(sb);return sb.toString();}

http://www.ppmy.cn/devtools/38380.html

相关文章

242.有效字母的异位词

给定两个字符串 s 和 t &#xff0c;编写一个函数来判断 t 是否是 s 的字母异位词。 注意&#xff1a;若 s 和 t 中每个字符出现的次数都相同&#xff0c;则称 s 和 t 互为字母异位词。 示例 1: 输入: s "anagram", t "nagaram" 输出: true示例 2: 输…

flutter日期选择器仅选择年、月

引入包&#xff1a;flutter_datetime_picker: 1.5.0 封装 import package:flutter/cupertino.dart; import package:flutter/material.dart; import package:flutter_datetime_picker/flutter_datetime_picker.dart;class ATuiDateTimePicker {static Future<DateTime> …

Java | Leetcode Java题解之第78题子集

题目&#xff1a; 题解&#xff1a; class Solution {List<Integer> t new ArrayList<Integer>();List<List<Integer>> ans new ArrayList<List<Integer>>();public List<List<Integer>> subsets(int[] nums) {dfs(0, nums…

标准引领 | 竹云参编《面向云计算的零信任体系》行业标准正式发布!

近日&#xff0c;中华人民共和国工业和信息化部公告2024年第4号文件正式发布行业标准&#xff1a;YD/T 4598.1-2024《面向云计算的零信任体系 第1部分&#xff1a;总体架构》&#xff08;后简称“总体架构”&#xff09;&#xff0c;并于2024年7月1日起正式实施。 该标准汇集大…

网站localhost和127.0.0.1可以访问,本地ip不可访问解决方案

部署了一个网站, 使用localhost和127.0.0.1加端口号可以访问, 但是使用本机的ip地址加端口号却不行. 原因可能有多种. 可能的原因: 1 首先要确认是否localhost对应的端口是通的(直接网址访问), 以及你无法访问的那个本机ip是否正确(使用ping测试)&#xff1b; 2 检查本机的防火…

【CSS基础--CSS选择器的常见用法】

CSS选择器的常见用法 1.CSS介绍1.1 基本语法规范1.2 引入样式1.3 规范 2. CSS选择器2.1 标签选择器2.2 类选择器2.3 ID选择器2.4 复合选择器 1.CSS介绍 CSS&#xff08;Cascading Style Sheet&#xff09;&#xff0c;层叠样式表&#xff0c;由于控制页面的样式。CSS能够对网页…

2024-05-08 postgres-火山模型-执行-记录

摘要: 2024-05-08 postgres-火山模型-执行-记录 上下文: 2024-05-08 postgres-调试及分析-记录-CSDN博客 火山模型: 数据流是在查询树上&#xff0c;自上而下进行拉取&#xff0c;由上而下的调用。树本身就表明了数据的流动。每次执行一个元组&#xff0c;也就类似于迭代器的…

C++ | Leetcode C++题解之第72题编辑距离

题目&#xff1a; 题解&#xff1a; class Solution { public:int minDistance(string word1, string word2) {vector<vector<int>> dp(word1.size() 1, vector<int>(word2.size() 1, 0));for (int i 0; i < word1.size(); i) dp[i][0] i;for (int j…