php - Unknown column 'expiry_date' in 'where clause' my sql query -


i have multiple tables , using following query filter records expiry_date not expired yet.

my query:

select      mt.id,     concat(mem.name,' ',mem.last_name) name,     ifnull((select max(mft.membership_end_date)          membership_future_transaction mft          mft.membership_transaction_id = mt.id),mm.end_date) expiry_date,     mem.phone,     mem.email,     mmst.name membership_name,     mmst.price,     mmst.session     membership_transaction mt     left join member_master mem on mem.id = mt.member_id     left join members_membership mm on mm.membership_transaction_id = mt.id     left join membership_master mmst on mmst.id = mt.membership_id     mt.is_casual = 'no'     , mt.is_deleted = 'no'     , mm.is_cancelled = 'no'     , expiry_date >= '2016-01-01'" 

but unknown column 'expiry_date' in 'where clause' error please me missing here.

mysql has perhaps nifty feature can use having alias. if change where clause to:

where mt.is_casual = 'no' ,       mt.is_deleted = 'no' ,       mm.is_cancelled = 'no' having expiry_date >= '2016-01-01'" 

then should work. of course, won't work expect query group by.


Comments

Popular posts from this blog

java - Andrioid studio start fail: Fatal error initializing 'null' -

android - Gradle sync Error:Configuration with name 'default' not found -

StringGrid issue in Delphi XE8 firemonkey mobile app -