.header on
.mode column

drop table if exists Member;
drop table if exists Visits;
drop table if exists Gym;

create table Member (
  mid,
  city
);

create table Visits (
  mid,
  gid
);

create table Gym (
  gid,
  city
);

insert into Member values  (1,"Seattle"),(2,"Seattle"),(3,"Bellview") ;

insert into Gym values (4,"Seattle"), (5,"Bellview"), (6,"Seattle");

insert into Visits values (1,4), (1,4) , (1,6);
insert into Visits values (2,4), (2,5) , (2,6);
insert into Visits values (3,5), (3,5) , (3,5);


select distinct *
from Member M
Left outer join Visits V on M.mid = V.mid 
left outer join Gym G on V.gid = G.gid and M.city <> G.city
group by M.mid
having count(G.gid) = 0;
