I have this query in yii2 :
SELECT COUNT(*)
FROM `agencias`
LEFT JOIN `responsables` `rsp`
ON `agencias`.`responsable` = `rsp`.`responsable_id`
LEFT JOIN `receptores` `rec`
ON `agencias`.`receptor` = `rec`.`receptor_id`
WHERE (`nombre` LIKE '%pru%')
AND (nombres LIKE "%%" or apellidos LIKE "%%")
But i get the message 'Column 'nombre' in where clause is ambiguous' i know how to fix this error setting an alias for the where conditions but dont know how to this is in yii2 activequery.
So the question is how i can set aliases for the where conditions to get a query like this :
SELECT COUNT(*)
FROM `agencias`
LEFT JOIN `responsables` `rsp`
ON `agencias`.`responsable` = `rsp`.`responsable_id`
LEFT JOIN `receptores` `rec`
ON `agencias`.`receptor` = `rec`.`receptor_id`
WHERE (`nombre` LIKE '%pru%') as alias1
AND (nombres LIKE "%%" or apellidos LIKE "%%") alias 2
agencias.beforenombre? (considering this column is indeed in theagenciastable)