SQL Query to Retrieve Latest Record Based on Date for Specific User
To select the most recent record based on the 'actime' column, you can use the following SQL query:
SELECT adjust_date AS actime, adjust_person AS person
FROM uf_adjust_history
WHERE adjust_person IN (' + userid1 + ')
ORDER BY actime DESC
LIMIT 1
This query will retrieve the 'adjust_date' as 'actime' and 'adjust_person' as 'person' columns from the 'uf_adjust_history' table for the specified 'adjust_person' values. The records will be sorted in descending order based on the 'actime' column and only the first record will be returned, which will be the most recent one.
原文地址: https://www.cveoy.top/t/topic/pZul 著作权归作者所有。请勿转载和采集!