mysql - Use the result of a Subquery in WHERE CLAUSE -
I am trying to use the result of a subquery in the WHERE section of the query that I want to use is the attribute See last_contact below.
selected last_contact as pre-name, surname, type, (select max (completed_date) from tblTasks where prospect_id = tblProspects.prospect_id and complete = '1'), where tblProspects created_at hidden Happened! = '1' and type = 'Prospect' and last_contact & gt;
I get a SQL error: # 1054 - In the unknown column 'last_contact' where 'clause'
P> Any help would be greatly appreciated.Thank you.
You need to use order to refine your results by custom alias coulmn > Segment where they are the segment
pre-selected names, aliases, types, (Max can not be used in the completed_date selection)! TblTasks from where prospect_id = tblProspects.prospect_id and complete = 'Last_contact', 'where' created from tblProspects hidden = '1' and type = 'probability' (last_contact); DATE_ADD (CURDATE (), interval-90DAY) or last_contact is IS NULL) ORDER BY Last_contact SC