<?php

$SQL = "create view view_usersubscriptions as

          select usersubscriptions.*, subscriptions.*,
                 date_format(usersubscription_timestamp, '%m/%d/%Y %l:%i %p') as usersubscription_timestamp_verbose,
                 date_format(usersubscription_stop_date, '%m/%d/%Y')          as usersubscription_stop_date_verbose,
                 
            case when usersubscription_stop_date < CURDATE()  then 'EXPIRED' else 'ACTIVE'  end as usersubscription_status
              
            from usersubscriptions
            
        left join subscriptions
               on subscriptions.subscription_serial = usersubscriptions.usersubscription_subscription_serial
               
        order by usersubscriptions.usersubscription_stop_date desc";
?>