It is suitable for the case of primary key self-increment, even if the creation time is in a few cases, it does not affect, because the search is based on the self-incremented primary key (the latest data primary key is definitely the largest, that is, the latest data is inserted into the database)
select id, msg_content, msg_create_time
from safety_promotion_msg spm
inner join (select max(id) max_id from safety_promotion_msg group by msg_content) a on a.max_id = spm.id;
If the primary key does not increase automatically, take the maximum time, that is max(msg_create_time)
, use the timestamp in the creation time field to prevent the creation time from being consistent and ensure the highest accuracy.