title: How to use MINUS operator in SQL?
body: <p>I want to retrieve all the details of bookings table which didn’t make the payment. I have used MINUS operator. But it didn’t work. It gives SQL Error. How to get bookingid which doesn’t exist in payments table. </p>
  
  <p>This is my code.</p>
  
  <pre><code>$SQL ="SELECT bookingid FROM bookings WHERE checkindate &gt;= '$new_date_in' AND checkoutdate &lt;= '$new_date_out' MINUS  SELECT bookingid FROM payments ";
          $run=mysql_query($SQL,$con) or die ("SQL error");
  </code></pre>
  
  <p>----$new_date_in and $new_date_out are user selected start and end dates---</p>
  
  <p><a href="http://i.stack.imgur.com/75cMg.jpg" rel="nofollow">Bookings Table</a></p>
  
  <p><a href="http://i.stack.imgur.com/KN5s7.jpg" rel="nofollow">payments table</a></p>