我有两个表,mytableA 和 mytableB。
MytableA 看起来像这样
ColumnA|Columnb
Apple|fruitstand
Pear|fruitstand
mytableB 看起来像这样:
A列|B列|C列 苹果|2|2012 年 4 月 1 日 苹果|3|2012 年 4 月 3 日 苹果|23|12/1/2011 梨|1|12/22/2011 梨|0|2012/4/22
我的查询是这个
select *
from
mytableB
join mytableB on mytableA.ColumnA = mytableB.ColumA
and mytableB.Columnc = (select max(Columnc) from mytableB b where b.ColumnA = mytableB.columnA)
我正在寻找的结果是
苹果|3|2012 年 4 月 3 日 梨|0|2012/4/22
我知道这在 SQL 中有效,但 mysql 有类似的方法吗?