select name,
from tablo 1 as X, tablo 1 as Y,
where X.ip == Y.ip AND online==1,
grouo by ip

Gibi bir şey olması lazım, olmazsa tekrar deneriz