关联条件查询

浏览:2237 发布日期:2018/02/05 分类:求助交流 关键字: hasWhere 关联条件查询

有这两个表,代码如下:$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.
怎么写才能得到我想要的结果呢?
最佳答案
评论( 相关
后面还有条评论,点击查看>>