这是我的表格数据和使用的查询,我通过 JSP 获取数据。
mysql> select * from allergy;
+---------+----------------+--------------+-------------------+-----------------+
| allergy | reaction | note | email | time |
+---------+----------------+--------------+-------------------+-----------------+
| stomach | Abdominal Pain | ksadjlkah | xyz@gmail.com | 9/8/17 2:20 PM |
| fever | Abdominal Pain | hevy | xyz@gmail.com | 4/9/17 11:29 AM |
+---------+----------------+--------------+-------------------+-----------------+
以类似的方式,我在单个 EmailID 下有很多记录。但这是我的问题我需要根据时间或其他方式显示最近更新的记录。任何人都可以帮我解决这个问题。 我的预期输出是
+---------+----------------+--------------+-------------------+-----------------+
| allergy | reaction | note | email | time |
+---------+----------------+--------------+-------------------+-----------------+
| fever | Abdominal Pain | hevy | xyz@gmail.com | 4/9/17 11:29 AM |
+---------+----------------+--------------+-------------------+-----------------+
答案 0 :(得分:0)
这应该为您提供所需的输出:
select * from allergy order by str_to_date(time,'%d/%m/%Y %h:%i %p')
desc limit 1;