Suppose the following table that records author posts in a blog.
An author can have several posts.
So I have several reps of authors on this table of the different posts he made.
How do I make a query to fetch the content of the most recent post according to the data_post column.
For example, the author of id_autor = 1 his most recent post is from 25-08-2018 with the science content.
I did the following search but it is returning the political content to me instead of sciences:
Resultwithgroupby: Inquiry:
SELECTid_post,id_autor,MAX(data_post),conteudo_postFROMtestegroupbyid_autororderbydata_postDESC;
Ifyouwanttoreplicatetheexample,followthecreateandjsfidlejsonifyouwanttoimportthedata. link
CREATE TABLE 'teste' (
'id_post' int(11) NOT NULL,
'id_autor' int(11) NOT NULL,
'data_post' date DEFAULT NULL,
'conteudo_post' varchar(45) DEFAULT NULL,
PRIMARY KEY ('id_post')
) ENGINE=InnoDB DEFAULT CHARSET=latin1;