- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有 3 个表来获得所需的输出(最新文件路径):-
I want to get- all distinct events with their filepath where creation_time of event media Table is MAX such that i can have all events with their updated filepath
MySQL 查询:-
select e.event_id, m.filepath, em.creation_time as latest from event e join event_media em on e.event_id=em.event_id join media m on em.media_id = m.media_id where em.creation_time=(select MAX(em.creation_time) from event_media where em.event_id =e.event_id);
输出:-
+----------+------------------------------------------------------------------------------------+---------------------+
| event_id | filepath | latest |
+----------+------------------------------------------------------------------------------------+---------------------+
| 1000055 | http://localhost:3000/static/images/glasoimage/event1.jpg | 2017-07-06 02:06:30 |
| 1000056 | http://localhost:3000/static/images/glasoimage/event2.jpg | 2017-07-06 02:15:15 |
| 1000058 | http://localhost:3000/static/images/glasoimage/event3.jpg | 2017-07-06 02:22:17 |
| 1000059 | http://localhost:3000/static/uploads/media/upload_b46a5d6f37f1c77a17b87fcbe5ccb975 | 2017-07-06 02:23:17 |
| 1000066 | http://localhost:3000/static/images/glasoimage/event6.jpg | 2017-07-06 17:10:59 |
| 1000057 | http://localhost:3000/static/uploads/media/upload_12b7a15dfae2ce4f7864c957b8ecf5a6 | 2017-07-06 02:20:52 |
| 1000062 | http://localhost:3000/static/images/glasoimage/event4.jpg | 2017-07-06 16:45:22 |
| 1000063 | http://localhost:3000/static/images/glasoimage/event5.jpg | 2017-07-06 16:47:30 |
| 1000071 | http://localhost:3000/static/uploads/media/upload_d00ab7878fcf6bacdbf800249678b818 | 2017-07-15 14:10:36 |
| 1000071 | http://localhost:3000/static/uploads/media/upload_0c85d276316550ef33e2f274635b99c7 | 2017-07-15 23:42:03 |
| 1000072 | http://localhost:3000/static/images/defaults/default-image.jpg | 2017-07-15 23:29:24 |
| 1000073 | http://localhost:3000/static/images/defaults/default-image.jpg | 2017-07-16 12:21:57 |
| 1000074 | http://localhost:3000/static/images/defaults/default-image.jpg | 2017-07-16 12:25:09 |
| 1000075 | http://localhost:3000/static/images/defaults/default-image.jpg | 2017-07-16 13:40:11 |
| 1000076 | http://localhost:3000/static/images/defaults/default-image.jpg | 2017-07-16 13:43:10 |
| 1000077 | http://localhost:3000/static/images/defaults/default-image.jpg | 2017-07-16 14:04:58 |
| 1000067 | http://localhost:3000/static/images/defaults/default-image.jpg | 2017-07-13 21:55:21 |
| 1000068 | http://localhost:3000/static/uploads/media/upload_d32e3685c22232d00602e827f55f6f64 | 2017-07-13 22:45:04 |
| 1000069 | http://localhost:3000/static/uploads/media/upload_e0aab7ea8150ee5e7e1f55d98366e51f | 2017-07-13 22:47:50 |
+----------+------------------------------------------------------------------------------------+---------------------+
19 rows in set (0.18 sec)
对于输出中第 9 行和第 10 行的事件 ID 1000071,我有两个文件路径:旧文件路径和新文件路径。
I want the new Filepath only with no duplication of event Id
提前致谢
最佳答案
您可以使用 group by 和 max 连接
select
e.event_id
, m.filepath
, em.creation_time as latest
from event e
join event_media em on e.event_id=em.event_id
join media m on em.media_id = m.media_id
join (
select
event_id
, MAX(creation_time) as max_time
from event_media
group by event_id
) t on t.event_id = em-event_id and em.creation_time = t.max_time
关于mysql - 无法在 join 中获得 MAX 时间,但具有不同的 id MySQL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45131576/
快速且可能简单的 Lambda 问题: 我有一家有评论的餐厅。我想查询具有以下内容的那个: 最大(平均评分) 和 Max(ReviewCount) 和 Max(NewestReviewDate) 和
在尝试使用 C++17 折叠表达式时,我尝试实现 max sizeof ,其中结果是类型 sizeof 的最大值。我有一个使用变量和 lambda 的丑陋折叠版本,但我想不出一种使用折叠表达式和 st
我目前正在使用 C 并遇到了一些我觉得有趣的东西,但似乎在这里找不到任何类似的东西。 我正在为数组(大小 1000000)静态分配内存。我知道这相当大并且有可能引起问题。但是,使用 10^6 不会出现
我有一个具有 max-height 的 div 和其中的图像,应该使用 max-width:100% 和 max-height:100%。在 Chromium 中,这是可行的,但 Firefox 仅使
我有一个最大高度的 div 和里面的一个图像,它应该使用最大宽度:100% 和最大高度:100%。在 Chromium 中,这是可行的,但 Firefox 仅使用最大宽度而忽略最大高度。 div#ov
在一本在线 awk 手册中我找到了例子awk '{ if (NF > max) max = NF } END { print max }' 该程序打印任何输入行上的最大字段数。但我不明白 awk 如何
按照目前的情况,这个问题不适合我们的问答形式。我们希望答案得到事实、引用或专业知识的支持,但这个问题可能会引发辩论、争论、投票或扩展讨论。如果您觉得这个问题可以改进并可能重新打开,visit the
我正在制作一个非循环图数据库。 表 Material (id_item,id_collection,...)主键(id_item,id_collection) (item可以是collection本身
我有以下两个表。 1.电影详情(电影ID、电影名称、评分、票数、年份) 2.电影类型(Movie-ID,Genre) 我正在使用以下查询来执行连接并获得每个评分最高的电影流派。 select Movi
我有一个查询,我想返回 idevent 中给定传感器 ID (sensorID) 范围内的最高 ID 值,但是查询没有返回最高值。 我运行查询时减去 max() 语句的结果: mysql> SELEC
SUM(MAX() + MAX()) 有正确的方法吗? 这是我一直在努力做的事情 SELECT SUM(MAX(account.BALANCE1) + MAX(account.BALANCE2))
这个问题类似于CSS media queries: max-width OR max-height , 但由于我的代表不够高,我无法在回复中添加评论(问题),我想在原始问题中添加。 与其他主题中的发帖
Jon Skeet今天报告(source): Math.Max(1f, float.NaN) == NaN new[] { 1f, float.NaN }.Max() == 1f 为什么? 编辑:双倍
这个问题已经有答案了: Java 8 stream's .min() and .max(): why does this compile? (5 个回答) 已关闭 7 年前。 我正在学习1z0-809
我在处理一些数据库记录时遇到了一些挑战。 我需要为特定列获取具有 MAX 值的行,并且这些记录必须介于两个时间戳值之间。 这是SQL查询 SELECT id, MAX(amount), created
我想在媒体查询中使用 AND 条件。我使用了下面的代码,但是没有用 @media screen and (max-width: 995px AND max-height: 700px) { } 最佳答
在编写 CSS 媒体查询时,有什么方法可以用“或”逻辑指定多个条件吗? 我正在尝试做这样的事情: /* This doesn't work */ @media screen and (max-widt
我对仅使用 max(list array) 和 np.max(list array) 之间的区别有疑问。 这里唯一的区别是 Python 返回代码所需的时间吗? 最佳答案 它们在边缘情况下可能不同,例
例如: a = [[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.
这个问题在这里已经有了答案: Java 8 stream's .min() and .max(): why does this compile? (5 个答案) 关闭 6 年前。 我正在学习 1z0
我是一名优秀的程序员,十分优秀!