php - MySQL select datetime for expired subscriptions -


i have table called "subscriptions" these columns:

  • id
  • client_id
  • date
  • expiring

i select values subscriptions expired , don't have ongoing subscriptions.

for example have these records in table:

id | client_id | date | expiring
1 | 23 | 2015-07-07 08:26:08 | 2015-07-27 08:26:08
2 | 23 | 2015-07-10 08:26:08 | 2015-07-15 08:26:08
3 | 21 | 2015-07-14 08:26:08 | 2015-07-15 08:26:08

that means result should show me client id 21 not client id 23 since has active subscription.

i hope explained well.

thanks in advance

select * subscriptions  client_id not in (     select client_id subscriptions      expiring > now()) 

Comments