
有这两个表,代码如下:
$keyword1 = '蔬菜';
$keyword2 = '瓜';
//查询product条件
$where['name'] = ['like', '%'.$keyword2.'%'];
//查询category条件
$hasWhere['name'] = ['like', '%'.$keyword1.'%'];
$list = productModel->hasWhere('category', $hasWhere)->where($where)->select();我想要得到的结果是: category名称为 '蔬菜' AND product名称包含 '瓜'字的所有product列表.用上面的查询语句报错:Integrity constraint violation: 1052 Column 'id' in where clause is ambiguous.
怎么写才能得到我想要的结果呢?
最佳答案