Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7653865
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T12:07:57+00:00 2026-05-31T12:07:57+00:00

I have a doubt to be clarified. How can i fetch the last value

  • 0

I have a doubt to be clarified. How can i fetch the last value inserted into sqlite DB. I need code for that.I tried using query like this:

SELECT uname,umessage,utime FROM chatmessage ORDER BY utime DESC limit 1;

Where am i doing wrong?? I need help in this issue.

Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T12:07:58+00:00Added an answer on May 31, 2026 at 12:07 pm

    if the value is last its id should be maximum

    you can fire the query like this

    c = db.rawQuery("SELECT uname,umessage,utime FROM tablename WHERE " +
                    "Id = (SELECT MAX(Id) FROM tablename ); ",null);
    

    for last message by particular user add user id column in the message table like

    id | userid | message | utime
    
    
    1  |   1    | wlhf    | 3:10
    
    2  |   3    | dfhhfjh | 2:15
    
    3  |   1    | kjfedhr | 4:00
    
    4  |   2    | hejhe   | 1:15
    
    5  |   3    |  kegekr | 3:30
    
    6  |   1    | wlhf    | 3:10
    
    7  |   3    | dfhhfjh | 2:15
    
    8  |   1    | kjfedhr | 4:00
    
    9  |   2    | hejhe   | 1:15
    
    10  |   3    |  kegekr | 3:30
    
    
    
    
    c = db.rawQuery("
    select message  from table1 where 
    
    
    userid  = 1 ; ",null);
    
    
    
    
    recieve like
    
    
    
    ArrayList<String> listMessg = new ArrayList<String>();
    
    
    
    cursor = dbm.columnValueofCourse();
            cursor.moveToFirst();
            startManagingCursor(cursor);
    
    for (int i = 0; i < cursor.getCount(); i++) {
    
        reciv = cursor.getString(cursor
                        .getColumnIndex("message"));
    listMessg.add(reciv_Par);
    }
    
    int sizeoflist = listMessg.size();
    
    because in ascending order , the last index 
    of array list will be the last message of the user
    
    System.out.println("THE LAST MESSAGE BY USER IS  " + listMessg.et(sizeoflist -1));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a doubt to be clarified. I am able to fetch the buddylist
i have doubt about how can i iterate into a group of div, my
I have a doubt using FileSystemWatcher in C#. I need to be notified when
I have doubt whether we can achieve multiple inheritence using 'module' concept or Is
I have a doubt that a static class can contain a private constructor.
I have doubt and need some suggestion on following code, NSArray* onscreenwindows = (NSArray*)CGWindowListCopyWindowInfo(kCGWindowListOptionOnScreenOnly,
I have some doubt on below code #include<stdio.h> int i=6; int main() { int
I have these lines of code that I use as a Factory to create
I'm new in sql. I have doubt. Let's say that I have two tables.
I have a doubt with enums if I defined a enums that inherited from

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.