Springboot annotations are used for full table fuzzy query, and the query result set is empty.

1. I am a rookie, in the process of learning springboot to do annotation mode of the full table fuzzy query, the result set of the query is always empty, but the sql statement in the navicat test can normally find the data, please answer the doubt, thank you very much.

2. I searched all the major websites for a long time, but I didn"t get a solution.

3.mapper method
@ Select ("SELECT id,parent_name,title,content,publish_time FROM tb_article WHERE CONCAT (id,parent_name,title,content) LIKE-sharp {params}")

public List<Article> selectParams(String params);

4.controller method
@ RequestMapping (value= "/ selectParam", method=RequestMethod.POST)

@ResponseBody
public List<Article> selectParam(@RequestParam String param){
    System.out.println(param);
    String params=""%"+param+"%"";
    System.out.println(params);
    if(params.equals("") || params==null) {
        return asi.selectArticleAll();
    }else {
        return asi.selectParams(params);
    }
}

Test statement in 5.navicat
SELECT id,parent_name,title,content,publish_time FROM tb_article WHERE CONCAT (id,parent_name,title,content) LIKE"% 1%"

clipboard.png

6.postman

clipboard.png

7. Please answer your doubts, thank you very much

May.30,2022

LIKE CONCAT ('%',-sharp {params},'%')

@ResponseBody
public List<Article> selectParam(@RequestParam String param){
    if(params !=null && !"".equals(params)) {
        return asi.selectParams(params);
    } else {
        return asi.selectArticleAll();
    }
}

@Select("SELECT id,parent_name,title,content,publish_time FROM tb_article WHERE CONCAT(id,parent_name,title,content) LIKE '-sharp{params}'")

try changing the single quotation marks

@ResponseBody
public List<Article> selectParam(@RequestParam String param){
    System.out.println(param);
    String params="%"+param+"%";
    System.out.println(params);
    if(params.equals("") || params==null) {
        return asi.selectArticleAll();
    }else {
        return asi.selectParams(params);
    }
}
Menu