有时我们希望在表中多个字段检索是否有我们给出的关键字,我们可以使用 concat_ws 和 concat 连接需要检索的字段,如:

select * from userInfo where concat(`user_name`,`email`) like '%root%';

或者:

select * from userInfo where concat_ws(',',`user_name`,`email`) like '%root%';

  CONCAT_WS() 代表 CONCAT With Separator ,是CONCAT()的特殊形式。但是要注意一点,如果连接的字段中有为空,那么concat会返回空串,concat_ws则不会返回空串

相关文章:

  • 2022-12-23
  • 2021-07-01
  • 2022-02-15
  • 2021-11-23
  • 2022-02-14
  • 2021-07-19
  • 2021-10-24
  • 2021-11-22
猜你喜欢
  • 2022-12-23
  • 2021-12-21
  • 2022-12-23
  • 2021-08-19
  • 2022-12-23
  • 2021-06-21
  • 2022-12-23
相关资源
相似解决方案