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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T06:21:02+00:00 2026-05-28T06:21:02+00:00

I have the follow two mysql tables: mysql> desc subscriptions; +————+————–+——+—–+———+—————-+ | Field |

  • 0

I have the follow two mysql tables:

mysql> desc subscriptions;
+------------+--------------+------+-----+---------+----------------+
| Field      | Type         | Null | Key | Default | Extra          |
+------------+--------------+------+-----+---------+----------------+
| id         | int(6)       | NO   | PRI | NULL    | auto_increment |
| id_user    | int(6)       | NO   | MUL | NULL    |                |
| id_package | int(4)       | NO   |     | NULL    |                |
| expiry     | date         | YES  |     | NULL    |                |
| ip         | varchar(100) | NO   |     | NULL    |                |
| amount     | double       | NO   |     | NULL    |                |
| processed  | tinyint(4)   | NO   |     | NULL    |                |
+------------+--------------+------+-----+---------+----------------+
7 rows in set (0.00 sec)


mysql> desc packages;
+----------+--------------+------+-----+---------+----------------+
| Field    | Type         | Null | Key | Default | Extra          |
+----------+--------------+------+-----+---------+----------------+
| id       | int(6)       | NO   | PRI | NULL    | auto_increment |
| id_panel | tinyint(4)   | NO   |     | NULL    |                |
| name     | varchar(100) | NO   |     | NULL    |                |
| price    | double       | NO   |     | NULL    |                |
| period   | varchar(50)  | NO   |     | NULL    |                |
| days     | int(11)      | NO   |     | NULL    |                |
| visible  | tinyint(4)   | NO   |     | NULL    |                |
| payment  | tinyint(4)   | NO   |     | 1       |                |
+----------+--------------+------+-----+---------+----------------+
8 rows in set (0.00 sec)

I’m using the follow query to retrive all the packages and the relative USER expirations date (of the specific package).

SELECT packages.id, packages.name, packages.price, packages.period, packages.days, MAX(subscriptions.expiry) as expiry
FROM packages LEFT JOIN subscriptions
ON subscriptions.id_package = packages.id AND subscriptions.processed = 1 AND subscriptions.id_user = 1
WHERE packages.visible = 1
GROUP BY subscriptions.id_user
ORDER BY packages.id_panel

My problem is that if there is not the subscription of a specific package the query does not show the package.

I MUST show all the page and….IF the user has a subscription check the MAX expiry date (becase i track all the subscrions the user made).

How can i show all the packages and the relative user expiration dates? (and if there is no subscription of a package show NULL)

  • 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-28T06:21:02+00:00Added an answer on May 28, 2026 at 6:21 am

    You’re grouping by subscriptions.id_user, yet you select all your non_aggregates from the packages table. Are you sure that you’re grouping by the correct field?

    It looks like it should be packages.id…

    • 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 database, Locations and Tags, and a third
I have two mySQL tables as follows: [product] table P_id | Name | Quantity
I have data spread over two MySQL tables with different structures. One table has
I have two mysql tables, one listing article names, the other listing the authors
I have two tables in my MySQL database, users and tweets, as follows: TABLE
I have two MySQL tables, with the following structure (I have removed irrelevant columns).
I have two tables as follows: tblCountry (countryID, countryCode) tblProjectCountry(ProjectID, countryID) The tblCountry table
If I have two tables - Logins and Users, as follows: Logins LoginIdNo UserIdNo
To illustrate, assume that I have two tables as follows: VehicleID Name 1 Chuck
I have two tables as follows: I have a RatingsTable that contains a ratingname

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.