SELECT
tipo_entidad.id,
tipo_entidad.descripcion,
tipo_entidad.vigente
FROM
tipo_entidad
INNER JOIN estado AS e ON e.valor = tipo_entidad.vigente
WHERE tipo_entidad.vigente=e.valor and
e.tabla = 'VIGENCIA' AND
(tipo_entidad.descripcion LIKE '%ad%' OR
e.descripcion_estado LIKE '%ad%')