title: How to retrive the last inserted id using mysql?
body: <pre><code> SELECT event.event_name, restaurants.res_name 
   FROM event_choices
   INNER JOIN restaurants
   ON event_choices.res_id = restaurants.res_id
   INNER JOIN event
   ON event_choices.event_id = event.event_id 
  </code></pre>
  
  <p>I am trying to get the last inserted records based on the <code>event_id</code> this query brings back all the records.</p>
  
  <p>similar to what <code>mysql_insert_id()</code> would do.</p>
  
  <p>Is it possible to modify the query to return only the last inserted record?</p>
  
  <p>my data looks like this I need to return the last <code>event_id</code> and its matching <code>res_id</code></p>
  
  <pre><code>event_id  | res_id
  116       | 1
  116       | 2
  </code></pre>