在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

相關文章
相關標籤/搜索