Nabi K.A.Z.
Nabi K.A.Z.

Reputation: 10704

compare two column that in relation

In Yii2, I need compare two column that in relation.

For example be like:

$query->andWhere(['product.form' => 'subcategory.form']);

build this query:

WHERE `product`.`form`='subcategory.form'

But I need be like this query:

WHERE `product`.`form`=`subcategory`.`form`

Upvotes: 1

Views: 443

Answers (1)

Nabi K.A.Z.
Nabi K.A.Z.

Reputation: 10704

I find the solution, It's easy with this code:

$query->andWhere('`product`.`form`=`subcategory`.`form`');

Upvotes: 1

Related Questions