在我的项目中,我允许用户搜索任何东西。 最近在Like查询中遇到问题。
Illegal mix of collations (latin1_swedish_ci,IMPLICIT) and (utf8mb4_unicode_ci,COERCIBLE) for operation 'like'
我得到了这个问题的解决方案,但是现在想在laravel查询中进行转换。
如何编写user.name,如_latin1“%aaa”COLLATE latin1_swedish_ci
this in->where()of laravel
我当前的查询代码是$query->where('user.name','like','%'.$search.'%');
您可以使用whereRaw
,如下所示
$query->whereRaw("user.name LIKE _latin1 '%aaa%' COLLATE latin1_swedish_ci");