ORDER BY id DESC LIMIT 3

时间:2016-12-17 11:01:13

标签: php select

伙计我在表格中有这样的数据:: 1,2,3,4,5,6,7,8,9,10

查询:

  SELECT done_sum FROM spent_vs_done WHERE project_id="14" ORDER BY id DESC LIMIT 3

我现在的结果如下:

10,9,8

我想得到最后3行:

8,9,10

您能否帮助我在查询中添加一些内容来实现这一目标。

MySQL的/ PHP

任何帮助都会得到赞赏!!!!

1 个答案:

答案 0 :(得分:1)

使用子查询来升序:

Dim ItemSubject As String
Dim SubFldr As String

i = 2 '  i = Row 2

With Worksheets("Sheet1") ' Sheet Name
   Do Until IsEmpty(.Cells(i, 1))

   ItemSubject = .Cells(i, 1).Value '(i, 1) = (Row2,Column1) = A2 Value = Subject
   SubFldr = .Cells(i, 2).Value '(i, 2) = (Row 2, Column 2) = B2 Value = FolderName

        '// Loop through Inbox Items backwards
        For lngCount = Items.Count To 1 Step -1
            Set Item = Items.Item(lngCount)

                If Item.Subject = ItemSubject Then ' if Subject found then
                    Set SubFolder = Inbox.Folders(SubFldr) ' Set SubFolder
                    Item.Move SubFolder ' Move to SubFldr
                End If

            End If
        Next ' exit loop

        i = i + 1 '  = Row 2 + 1 = Row 3
   Loop ' now loop on Row 3
End With