title: Matching two column values
body: <p>I have 2 tables. 'user_cities' and 'visits'. I want to check if a user visited a city which he was not supposed to visit.</p>
  
  <pre><code>CREATE TABLE `user_cities` (
      `id` INT NOT NULL AUTO_INCREMENT,
      `user_id` INT,
      `name` varchar(255),
      `city_id` INT,
    PRIMARY KEY (`id`)
  );
  
  CREATE TABLE `visits` (
      `id` INT NOT NULL AUTO_INCREMENT,
      `user_id` INT,
      `visit_id` INT,
      `city_id` INT,
      PRIMARY KEY (`id`)
  );
  
  INSERT INTO `user_cities` VALUES
  (1, 1, 'John', 35),
  (2, 1, 'John', 36),
  (3, 1, 'John', 37),
  (4, 2, 'Michael', 38),
  (5, 2, 'Michael', 39);
  
  INSERT INTO `visits` VALUES
  (1, 1, 1, 35),
  (2, 1, 2, 36),
  (3, 1, 3, 38),
  (4, 2, 4, 38),
  (5, 2, 5, 39);
  </code></pre>
  
  <p><a href="http://sqlfiddle.com/#!9/68c658" rel="nofollow noreferrer">http://sqlfiddle.com/#!9/68c658</a></p>
  
  <p>Example: John must visit only 35, 36 and 37. Michael must visit 38 and 39. These are defined in 'user_cities'</p>
  
  <p>However, John has visited 38 (visits id 3)</p>
  
  <p>How can i query users that visited the wrong city?</p>