locked
Select specific Boxid from table which is the latest entry RRS feed

  • Question

  • User810354248 posted

    In my asp.net+Vb+sql web i have a page to update a specific data.

    SQL Table 

    BoxinOut

    Id      BoxID         Date                          Branch         Status

    1       KK/CLT/01   21 Nov 2018           Bangalore     Out

    2       KK/CLT/02   18 Nov 2018           Calicut          In

    3       KK/CLT/02   21 Nov 2018           Palghat         Out

    if i want to select the third row which is the latest entry. I tried this but is not working

    "Select TOP 1 * from BoxInOut where BoxID='" + bidtxt.Text + "' ORDER BY BoxID DESC"

    Saturday, November 24, 2018 2:35 PM

Answers

  • User1281381861 posted

    For latest, you can run either of these:

    ... ORDER BY ID DESC

    or

    ...ORDER BY Date DESC

    and please parameterized your query to avoid SQL Injection.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, November 24, 2018 3:14 PM