find last two records

Ask a Question related to Coldfusion Database Access, Design and Development.

  1. #1

    Default find last two records

    Hi guys, problem,
    need to display last two records inserted into a database by date.two tables are joined by common columnname
    whats the best way to do that?
    using cf7 and mysql
    :confused;
    noodleweb Guest

  2. Similar Questions and Discussions

    1. trailing slash issue in Find.find
      require "find" Find.find("/usr/bin/") { |file| puts file } /usr/bin//rmdir /usr/bin//rm /usr/bin//mv /usr/bin//mknod /usr/bin//mkfifo...
    2. Cancel Find shows all records
      Due to some bad design decisions and the 50 file limit, we have a few files that contain records representing completely different things, each...
    3. After Find records then Omit (Active in field)
      After Find records (Birthday date in 30 days future) then omit inactive... so, I can see active only in 30 days future. How can I insert omit's...
    4. Find records by???
      I have a database with records and within this I have a field based on the date the record was created. How can I perform a find to automatically...
    5. How to find duplicate records in the table?
      I have a table with following columns: Part_nbr Desc QOH Price I want to make sure there is no duplicate part numbers and if there is and I...
  3. #2

    Default Re: find last two records

    One way is to sort the records by the date column in DESCending order, so the
    most recent are listed first. Then grab the first 2 rows. I don't know the
    exact syntax, but look in your documentation for the LIMIT command. It should
    be something like this

    --- NOT tested
    SELECT t1.SomeColumn, t1.SomeOtherColumn
    FROM table1 t1 INNER JOIN table2 t2 ON t1.CommonColumn = t2.CommonColumn
    ORDER BY t1.yourDateColumn DESC
    LIMIT 2


    mxstu Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139