title: SQL Query to select records based on 2 different values in the same field and a condition
body: <p>I Created a table like this for indian railways project:</p>
  
  <pre><code>CREATE TABLE IF NOT EXISTS `dennis` (
    `trid` varchar(50) NOT NULL,
    `place` varchar(50) NOT NULL,
    `si` varchar(50) NOT NULL
  ) ENGINE=MyISAM DEFAULT CHARSET=latin1;
  </code></pre>
  
  <p>then i inserted rows this way :</p>
  
  <pre><code>INSERT INTO `dennis` (`trid`, `place`, `si`) VALUES
  ('100', 'cochi', '3'),
  ('300', 'cochi', '1'),
  ('100', 'mumbai', '1'),
  ('100', 'bangalore', '2'),
  ('300', 'bangalore', '2'),
  ('300', 'mumbai', '3'),
  ('200', 'hyderabad', '1'),
  ('400', 'trivandrum', '1'),
  ('200', 'bangalore', '2'),
  ('200', 'trivandrum', '3'),
  ('400', 'bangalore', '2'),
  ('400', 'hyderabad', '3');
  </code></pre>
  
  <p>My problem is when i select start station as Bangalore and destination as mumbai, I am getting all the train numbers because bangalore exist for all trid ie trainid but mumbai exist only for 100 and 300.</p>
  
  <p>I need a query that can return only those trid who have both mumbai and bangalore. Also the si ie Serialnumber of bangalore must be lesser than si of mumbai.</p>
  
  <p>i used this query but it seems to return all the record</p>
  
  <pre><code>SELECT DISTINCT trid FROM dennis WHERE place ='mumbai' OR place='bangalore'
  </code></pre>