任何人都可以在yii2中構造這個子查詢嗎?yii2中的複雜子查詢
select name, crt_by, (select name from tbl_employee_master
where tbl_employee_master.contact = (select username from tbl_user
where tbl_user.id = tbl_dealer_master.crt_by)) as
employee, district, contact_person, contact,
(select count(*) from tbl_dealer_post
where tbl_dealer_post.fk_user_id = tbl_dealer_master.id)
as post_count from tbl_dealer_master
where status=1
幫助是明顯的! 在此先感謝!
你想用'activerecord'或'activequery'回答嗎? –
檢查了這一點http://stackoverflow.com/questions/30164491/yii2-subquery-in-active-record – Bloodhound