title: Select statement to get a specific row from an inner join
body: <p>The question I have is kind of simular to this one - <a href="https://stackoverflow.com/questions/10914079/mysql-select-1-row-from-inner-join">MySQL select 1 row from inner join</a></p>
  
  <p>However, it was never really answered in the way that I needed it. So I thought I would ask.</p>
  
  <p>I have a table A (tableA) and this table has a load of states in tableB. New states keep being added all the time.</p>
  
  <p>TableB has a column 'State' which has a foreign key to TableA.Id. This table B has a value and timestamp</p>
  
  <p>I am trying to get ONE query which will bring back ALL values in TableA, with an inner join to bring the LATEST 'value' of those rows from tableB. The latest being the one with the latest time.</p>
  
  <p>I know how to do an inner join where it needs to be, and I know how to order a table to bring back the latest 'time' row, however I dont know how to put these two together and create a single query.</p>
  
  <p>I'm sure I will have to have a Select within a select, which is fine. However, what I am trying to avoid is to bring a DataTable back with all my results from TableA and do a query for each of those on tableB seperately.</p>
  
  <p>Any ideas?</p>
  
  <p>EDIT - I have made a mistake with the question, I only really noticed when trying to implement one of the answers.</p>
  
  <p>I have a foreign key between TableA.id and TableB.proId</p>
  
  <p>TableA - 'Id', 'Name'
  TableB - 'Id', 'proId', 'State', 'time'</p>
  
  <p>I want to bring back all values of TableA with a join on B, to bring back the 'State' of the Max time</p>