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

  • Home
  • SEARCH
  • 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 8198719
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T06:00:38+00:00 2026-06-07T06:00:38+00:00

Say I have a table Connections with format [logID, user, time] An example set

  • 0

Say I have a table Connections with format [logID, user, time]

An example set be:

| logID |  user |  time 
|-----------------------
|  91   | terry | 12:55:00  <--- Last by user
|  90   | terry | 12:54:26
|  89   | nami  | 12:52:12  <--- Last by user
|  88   | terry | 12:50:50  <--- Last by user
|  87   | terry | 12:49:21
|  86   | terry | 12:48:16
|  85   | terry | 12:46:07
|  84   | nami  | 12:31:22  <--- Last by user
|  83   | nami  | 12:30:30
|  82   | nami  | 12:29:26 
|  81   | terry | 12:27:12  <--- Last by user

The desired query should GROUP the user column whenever it changes and select the last timestamp by that user:

| logID |  user |  time 
|-----------------------
|  91   | terry | 12:55:00  <--- Last by user
|  89   | nami  | 12:52:12  <--- Last by user
|  88   | terry | 12:50:50  <--- Last by user
|  84   | nami  | 12:31:22  <--- Last by user
|  81   | terry | 12:27:12  <--- Last by user

I’ve been playing around with GROUP BY, but haven’t gotten anywhere…

  • 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-06-07T06:00:39+00:00Added an answer on June 7, 2026 at 6:00 am

    One way would be using user variables:

    SELECT   logID, @lastuser:=user AS user, time
    FROM     mytable, (SELECT @lastuser:=NULL) init
    HAVING   NOT @lastuser<=>user
    ORDER BY time DESC
    

    See it on sqlfiddle.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Say for Instance I have the following table (full of connections between members) connectionA
Lets say I have table with following columns 1. Client - string. 2. Profit
Lets say I have table named Place with columns: placeId int not null auto_increment,
Lets say I have table with ID int, VALUE string: ID | VALUE 1
Say I have a table that goes clockwise like this: 2 1 3 0
Say I have a table: <table id=table1 border=1> <tr> <td id='id1' style=width:200px></td> <td id='id2'
Say I have this table schema. ID AccNo Amount Say I have this data
Say I have a table called HoursCharged ChrgNum(varchar(10)) CategoryID(uniqueidentifier) Month(datetime) Hours(int) CategoryID is a
Say I have a table named items : id int(11) ... tag int(11) And
Say I have a table with a unique positive integer field. I currently have

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.