select tb_member.m_id , tb_member.m_image , tb_member.m_name , tb_member.m_status , tb_friend.f_mid_at1 , tb_friend.f_mid_at2 , tb_friend.f_accept FROM tb_friend , tb_member WHERE tb_friend.f_accept ='YES' AND tb_member.m_id ='5' And tb_friend.f_mid_at1 = tb_member.m_id OR tb_friend.f_mid_at2 = tb_member.m_id GROUP BY tb_member.m_id HAVING tb_member.m_status ='Online'
select tb_member.m_id , tb_member.m_image , tb_member.m_name , tb_member.m_status , tb_friend.f_mid_at1 , tb_friend.f_mid_at2 , tb_friend.f_accept FROM tb_friend , tb_member WHERE tb_member.m_id NOT IN ('5') AND tb_friend.f_accept ='YES' AND tb_member.m_id ='5' And tb_friend.f_mid_at1 = tb_member.m_id OR tb_friend.f_mid_at2 = tb_member.m_id GROUP BY tb_member.m_id HAVING tb_member.m_status ='Online'