How to use an user variables in MySQL LIKE clause?

后端 未结 7 2065
逝去的感伤
逝去的感伤 2020-12-03 02:43

I am trying to setup a few simple SQL scripts to help with some short term DB administration. As such, I\'m setting up variables to try to make it easier to reuse these scri

相关标签:
7条回答
  • 2020-12-03 03:16

    No need to CONCAT just use '%'+ Variable +'%':

    SET @email = 'test@test.com';
    SELECT email from `user` WHERE email LIKE '%' + @email + '%';
    
    0 讨论(0)
提交回复
热议问题