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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T13:43:03+00:00 2026-05-30T13:43:03+00:00

I have a database that will store events. Each event has different activities. The

  • 0

I have a database that will store events. Each event has different activities. The database is made as so (I know this is not the best database design, but I am working with what was given to me) :

eventID | date       | eventname | activity
___________________________________________
0001    | 01/01/2012 | name1     | activty1
0002    | 01/01/2012 | name1     | activty2
0003    | 01/05/2012 | event2    | activty1
0004    | 01/05/2012 | event2    | activty2
0005    | 01/07/2012 | name1     | activty1

The same event can have multiple activities. The only way I can get the all records from an event (activities) is by the eventname column.

What I am trying to do is get the last 20 events with all it’s activities. Therefore I cannot simply select 20 rows (using LIMIT as this would not get me 20 events everytime as some events have 2 activities and others 10).

I cannot use SELECT DISTINCT eventname because some events have same name, on different dates. What I would need is to have a distinct eventname only if the date is different.

I’m lost for ideas.

Thanks.

  • 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-30T13:43:04+00:00Added an answer on May 30, 2026 at 1:43 pm
    SELECT
      *
    FROM
      event
    INNER JOIN
    (
      SELECT   eventName, Date
      FROM     events
      GROUP BY eventName, Date
      ORDER BY Date DESC
      LIMIT    20
    )
      AS last_20_events
        ON  last_20_events.eventName = events.eventName
        AND last_20_events.Date      = events.Date
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a PostgreSQL database with events. Each event has a datetime or an
I have a mysql database table that will store locations for buildings and events
I have a SQL Server 2000 database that will not display the column list
I'm a PHP noob. I have a database that I will update weekly with
We have a new filestream database that will be initially loaded with 65GB data,
I am creating a database that will help keep track of which employees have
I have a MySQL database, and a particular table in that database will need
I have a search program that will be looking at a database from a
I'm creating and app that will rely on a database, and I have all
I have a database that many different client applications (a smattering of web services,

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.