I have 2 tables.  Table A stores records, table B stores updates to table A.
In table A, there would be fields: id, name.
In table B, there would be fields: a_id, name, updated_at.
Any record in table A may have any number of related records in table B.
What sql query do I need to get records from table A, along with only the latest related update record from table B? (The idea is to get the latest updated_at value from table B for the associated record.)
This query
	
		
 unfortunately does not return the latest record from table B.  Even adding in an order to the query does not work.  Any ideas?
			
			In table A, there would be fields: id, name.
In table B, there would be fields: a_id, name, updated_at.
Any record in table A may have any number of related records in table B.
What sql query do I need to get records from table A, along with only the latest related update record from table B? (The idea is to get the latest updated_at value from table B for the associated record.)
This query
		Code:
	
	SELECT a.*, b.updated_at from a left outer join b on a.id = b.a_id group by a.id 
				
		 
			 
 
		 
 
		 
 
		 
 
		
 Facebook
Facebook Twitter
Twitter