在MyBatis中使用concat()方法

concat介绍

CONCAT(字串1, 字串2, 字串3, ...): 将字串一、字串二、字串3,等字串连在一块儿。sql

示例

SELECT CONCAT(region_name,store_name) FROM Geography
WHERE store_name = 'Boston';

应用场景

模糊查询

concat:this

Used to connect the field, or the characters. But as long as the field is connected with a value of null, then the concat get is null. 用于链接字段或者字符,若是用于链接的字符中有一个值为null,则结果为null.code

This is a very dangerous thing. I believe the number of fields connected with the concat the results people want most is not the case:get

你们使用concat的意图是:链接两个字符A,B,若是B为null,则链接结果为Ait

concat (A, B), if B is null, then concat (A, B) = nullio

What we want is this: 就像这样:class

Connection A, B, if B is null, then the connection should be A.sed

解决这个问题,可使用CONCAT_WS() At this time should CONCAT_WS (separator, str1, str2 ,...)im

相关文章
相关标签/搜索