Your problem is that you have put the wildcard characters into the call to UNHEX
instead of concatenating them outside it, and that is making UNHEX
return NULL
, which will always cause LIKE
to return false
.
Change
LIKE UNHEX('%{$name_2}%')
to
LIKE CONCAT('%', UNHEX('{$name_2}'), '%')
and your code will work as expected. Alternatively, you could do as @Akina suggested in the comments, and replace the %
signs in the call to UNHEX
with their hex representation (25
) and replace your code with
LIKE UNHEX('25{$name_2}25')
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…