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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T03:38:00+00:00 2026-05-28T03:38:00+00:00

I have two tables in a Mysql database. PACKAGES: ID (auto_increment) CATEGORY (INT) NAME

  • 0

I have two tables in a Mysql database.

PACKAGES:

ID (auto_increment)
CATEGORY (INT)
NAME (VARCHAR)
EXPIRY (VARCHAR)
VISIBLE (TINYINT)

EXAMPLE:

1 | 1 | Package AAA_1 | INTERVAL 7 DAY  | 1
2 | 2 | Package BBB_1 | INTERVAL 1 YEAR | 1
3 | 1 | Packaga AAA_2 | INTERVAL 14 DAY | 1

SUBSCRIPTIONS:

id (auto_increment)
id_user (INT)
id_package (INT) // It points to packages.id
date (DATETIME)

EXAMPLE:

1 | 1 | 1 | 2012-01-06 00:04:18

My problem is that a sigle user can have more subscriptions for the same package (because when a subscription expiry there will be a new subscription and I need to track all the previous subscription to know the “Story” of each user)

Now, I have to create a query to extract all the packages (where packages.visible=1 and ORDER BY packages.category) and

CHECK

What is the real expiration of that user package.

as you see I have subscriptions.date (it is the date when the user does the subscription), then i have to add at this date the packages.expiry to know the DATE of the real expiration. Obviously I ONLY have to add subscription.date + package.expiry to the LAST subscription the user made of that specific package.

EDIT:

Obviously I have to pass to this query the ID of the user I would like to check.

  • 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-28T03:38:01+00:00Added an answer on May 28, 2026 at 3:38 am

    This select statement will give you the information you need, but because the package expiry field appears to be free-form text I don’t think there’s a way to add it to the last subscription date.

    SELECT subscriptions.id_user, packages.name, MAX(subscriptions.date), packages.expiry
    FROM subscriptions JOIN packages ON subscriptions.id_package = packages.id
    WHERE packages.visible = 1
    GROUP BY subscriptions.id_user, subscriptions.id_package
    ORDER BY packages.category
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two tables in a MySql DB: items id (char) name (varchar) description
I have a mysql database with two tables: table1 (id, name, emailid) table2 (id,
I have a MySQL database with two tables in it: Members - id, name,
I have 10 tables in my database(MySQL). two of them is given below tbl_state
I have two tables in a MySQL database, Locations and Tags, and a third
I have two tables in a MySQL database, courses and sessions. I'm trying to
I have a MySQL database with two tables (simplified for this question): movies table
We have a MySQL database that has two tables, Warehouse and Crate Warehouse: WarehouseID
I have two tables from two different databases. For example: Table: Articles1 - Database:
I have two MySQL database tables that are meant to hold data for eshop

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.