有时我们希望在表中多个字段检索是否有我们给出的关键字,我们可以使用concat_ws和concat连接需要检索的字段,如:
select * from t_user where concat(`user_name`,`email`) like '%root%';
或者:
select * from t_user where concat_ws(',',`user_name`,`email`) like '%root%';
CONCAT_WS() 代表 CONCAT With Separator ,是CONCAT()的特殊形式。但是要注意一点,如果连接的字段中有为空,那么concat会返回空串,concat_ws则不会返回空串
4051

被折叠的 条评论
为什么被折叠?



