1390 prepared语句包含太多占位符

cxfofazt  于 2021-06-18  发布在  Mysql
关注(0)|答案(1)|浏览(388)

获取以下错误
sqlstate[hy000]:常规错误:1390准备语句包含太多占位符
我的查询最近由于表中的数据而变得

SELECT
  *
FROM
  table
WHERE col1 = 'some-val'
  AND col2 NOT IN ('va1', 'val2', 80k values... )

我用的是Laravel5.6

$data_will_be_skipped = OtherModel::select('code')
        ->where('col1', 0)
        ->orWhere('col2', 1)
        ->groupBy('col3')
        ->pluck('col3')->toArray();

$data\u将被跳过\u现在约为8万个数组

Model::where('col1', 'some-val')->whereNotIn('col2', $data_will_be_skipped)->get();
y0u0uwnf

y0u0uwnf1#

mysql在prepared语句中的参数限制为65535个。
改用子查询:

$data_will_be_skipped = OtherModel::select('col3')
    ->where('col1', 0)
    ->orWhere('col2', 1);
Model::where('col1', 'some-val')
    ->whereNotIn('col2', $data_will_be_skipped)
    ->get();

相关问题