select a.*, b.mb_no, b.mb_level, b.mb_1, b.state, b.mb_3, b.mb_4, b.mb_5, b.mb_6, b.use_phone, b.use_chat , b.mb_rising, b.mb_id
from g5_write_counselor a left join g5_member b on(a.mb_id=b.mb_id) where b.mb_level='5' and b.mb_leave_date='' and a.wr_is_comment = 0
and b.state='CONN' ORDER BY IF(b.state IN ('IDLE','RDVC','CONN'), 0, 1),
FIELD(b.state,'IDLE','RDVC','CONN',''),
b.mb_nick limit 0, 13