Yii2 innerJoin()

前端 未结 4 759
天命终不由人
天命终不由人 2021-01-12 16:06

I want to implement a sql query in the following way:

INNER JOIN
`Product_has_ProductFeature` t ON `Product`.`id` = t.`productId` AND t.`productFeatureValueI         


        
4条回答
  •  我在风中等你
    2021-01-12 16:31

    You can use the below code:

    $model = Product::find()
    ->innerJoinWith('t', 'Product.id = T.productId')
    ->andWhere(['T.productFeatureValueId' => ''])
    ->innerJoinWith('t1', 'Product.id = T1.productId')
    ->andWhere(['T1.productFeatureValueId' => '5'])
    ->all();
    

提交回复
热议问题