[英]Get the first and the last row from one table
I want to get the first and the last row from a table. 我想从表中获取第一行和最后一行。 Once i get that, i want to get another first and last row from another table.
一旦我得到了,我想从另一个表中得到另一个第一行和最后一行。
Is some strange i think, but this is it. 我觉得有些奇怪,但就是这样。
please, maybe somebody can give me an advice for what i want. 拜托,也许有人可以给我一些我想要的建议。
This is where i'm stuck : 这就是我被困的地方:
http://s14.postimage.org/sj9xgeofz/print.png http://s14.postimage.org/sj9xgeofz/print.png
Try using this:- 试试这个: -
SELECT column name
FROM table1
WHERE <conditions>
ORDER BY date DESC
LIMIT 1
UNION
SELECT column name
FROM table1
WHERE <conditions>
ORDER BY date ASC
LIMIT 1
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.