我当前正在使用此查询从invoiceNo不同的表中获取所有值。
SELECT * FROM `selected_items` WHERE invoiceNo IN ( SELECT DISTINCT ( invoiceNo) AS invoiceNo FROM selected_items ) GROUP BY invoiceNo;
这是我的表结构
我想从最后一行访问所有内容。我当前的查询给了我第一行。谢谢:)
最佳答案
使用order by rownum
或GROUP BY
Select * From (
SELECT t.*,
@rownum := @rownum + 1 AS rank
FROM selected_items t,
(SELECT @rownum := 0) r order by rank DESC
) si GROUP BY si.invoiceNo
关于php - 如何在mysql数据库的特定列中选择最后一个值?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/34353837/