相当于MS-Access函数first()last()的MYSQL [英] MYSQL equivalent of MS-Access function first() last()

查看:139
本文介绍了相当于MS-Access函数first()last()的MYSQL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为更好地解释我的需求,请查看下表:

To better explain what I need please look at this table:

ID --- image
A1 --- a1_01.jpg
A1 --- a1_02.jpg
B7 --- b7_01.jpg
B7 --- b7_02.jpg
D3 --- D3_04.jpg
D3 --- D3_99.jpg
... (From A to Z)
Z9 --- Z9_12.jpg
Z9 --- Z9_13.jpg
Z9 --- Z9_20.jpg
Z9 --- Z9_99.jpg
...and so on

我需要的结果是:

ID --- Image
A1 --- a1_01.jpg
B7 --- b7_01.jpg
D3 --- D3_04.jpg
...
Z9 --- Z9_12.jpg
...and so on

在MS-Access中,这可以通过SELECT ID, First(image) AS 'Image' FROM Photos

In MS-Access this is can be done with SELECT ID, First(image) AS 'Image' FROM Photos

如何在MYSQL中完成此操作?

请记住,这是一个样机表,以说明我的问题.我有无数的记录.它不是一个(最小/最大)值!

Remember that this is a mockup table, to illustrate my problem. I have tons and tons of records. IT IS NOT a single (least/most) value!

===11/24/2012 ===
最终的SQL代码:

=== 11/24/2012===
FINAL SQL CODE:

SELECT ID, Min(image) AS 'Image' 
FROM Photos 
GROUP BY ID

谢谢您 @triclosan & @iDevlop !!!

Thank you @triclosan & @iDevlop !!!

推荐答案

我可能会看到

select ID, min(image)
from tbl
group by ID

这篇关于相当于MS-Access函数first()last()的MYSQL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆