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 8853077
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T13:33:39+00:00 2026-06-14T13:33:39+00:00

I have a table with site visits with the following columns: timestamp host url

  • 0

I have a table with site visits with the following columns:

timestamp
host
url

I would like to see the last few (say 200) visits but at the same time group visits of the same host together (to see the sequence of pages he/she visits).

If I do:

... SORT BY timestamp DESC, host

I get hosts mixed up if several visitors are online at the same time

If I do:

... SORT BY host, timestamp DESC

I do not get the latest visits (just the latest visits from each host)

I would like to see e.g.

9:01 | a.com | /index
9:05 | a.com | /interesting
9:07 | a.com | /contact
9:02 | b.com | /index
9:03 | b.com | /product-a
9:08 | b.com | /thanks-for-buying

Is that possible in Mysql or should I further process the result in php?

  • 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-14T13:33:40+00:00Added an answer on June 14, 2026 at 1:33 pm

    The answers above pointed my in the right direction, thanks. This one works. The LIMIT 1000 is to reduce the query from almost 3 minutes to 7 seconds (40000 records).

    SELECT v1.stamp, v1.host FROM visits AS v1 
       LEFT JOIN (SELECT MIN(date) AS firstVisit, host
                  FROM visitor AS v2 
                  GROUP BY v2.host
                  ORDER BY firstVisit DESC
                  LIMIT 1000) AS j
           ON v1.host=j.host 
           ORDER BY firstVisit DESC, v1.host, v1.date DESC
           LIMIT 100;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a table row with 4 columns on my ecommerce site and I
I have a table named Site with columns Name , SiteId and Sequence .
I have a table that looks like this: Month Site Val 2009-12 Microsoft 10
I have table which contains columns like SiteID (identity_Col) SiteName POrderID Location Address Cluster
I have table where I track various statistics about site usage. Once a week,
We have a composite primary key for the site table defined below. Functionally, this
I have a posts table for my reddit-clone site and I'm wondering whether I
I have a database table containing the news on my site. It's divided into
I have been trying to parse the bottom table on this site using different
I have a site with multiple pages, and each page has a table that

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.