Alias variable is not working while using in condition client != id
select *,str_to_date(invoice_date,'%d/%m/%Y') as date,invoice_to as id,
(select mob_no from client_info where mob_no = id ) as client
from client_invoice
where client != id
having str_to_date(invoice_date,'%d/%m/%Y') >= '$fdate'
and str_to_date(invoice_date,'%d/%m/%Y') <= '$tdate'
ORDER BY date DESC
Please help to solve this issue. Thanks in Advance.