select * from ( SELECT t1.ttypedetailid, t1.fvalue, t1.ftype, t1.fparentid FROM ttypedetail t1 where t1.fparentid in (SELECT ttypedetailid FROM ttypedetail where fparentid = 1) and t1.fisused = 1 and $where$ UNION SELECT t1.ttypedetailid, t1.fvalue, t1.ftype, t1.fparentid FROM ttypedetail t1 WHERE t1.ttypedetailid in (SELECT ttypedetailid FROM ttypedetail_auth WHERE position in (SELECT wechat_position FROM tuser WHERE tuserid = $tuserid$)) and $where$ ) a order by ttypedetailid desc