Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- | 359338047 | ieltsadv | localhost | my_ieltsadvantage | Query | 1 | Sending data | SELECT
- u.ID AS user_id,
- (
- SELECT t.id
- FROM wp_mepr_transactions AS t
- WHERE t.user_id = u.ID
- AND t.status = 'complete'
- ORDER BY t.created_at ASC
- LIMIT 1
- ) AS first_txn_id,
- (
- SELECT t.id
- FROM wp_mepr_transactions AS t
- WHERE t.user_id = u.ID
- AND t.status = 'complete'
- ORDER BY t.created_at DESC
- LIMIT 1
- ) AS latest_txn_id,
- (
- SELECT COUNT(*)
- FROM wp_mepr_transactions AS t
- WHERE t.user_id=u.ID
- AND t.txn_type IN ('payment', 'sub_account')
- ) AS txn_count,
- (
- SELECT COUNT(*)
- FROM wp_mepr_transactions AS t
- WHERE t.user_id = u.ID
- AND t.status = 'complete'
- AND t.txn_type IN ('payment', 'sub_account')
- AND ( (
- t.expires_at IS NOT NULL
- AND t.expires_at <> '0000-00-00 00:00:00'
- AND t.expires_at < '2019-07-19 10:52:46'
- )
- )
- ) AS expired_txn_count,
- (
- SELECT COUNT(*)
- FROM wp_mepr_transactions AS t
- WHERE t.user_id=u.ID
- AND t.status = 'complete'
- AND t.txn_type IN ('payment', 'sub_account')
- AND (
- t.expires_at IS NULL
- OR t.expires_at = '0000-00-00 00:00:00'
- OR t.expires_at > '2019-07-19 10:52:46'
- )
- ) AS active_txn_count,
- (
- SELECT COUNT(*)
- FROM wp_mepr_transactions AS t
- JOIN wp_mepr_subscriptions AS sub
- ON t.subscription_id = sub.id
- WHERE t.user_id=u.ID
- AND t.txn_type = 'subscription_confirmation'
- AND (
- t.expires_at IS NULL
- OR t.expires_at = '0000-00-00 00:00:00'
- OR t.expires_at > '2019-07-19 10:52:46'
- )
- AND sub.trial IS TRUE
- AND sub.trial_amount = 0.00
- ) AS trial_txn_count,
- (
- SELECT COUNT(*)
- FROM wp_mepr_subscriptions AS s
- WHERE s.user_id=u.ID
- ) AS sub_count,
- (
- SELECT COUNT(*)
- FROM wp_mepr_subscriptions AS s
- WHERE s.user_id=u.ID
- AND s.status='pending'
- ) AS pending_sub_count,
- (
- SELECT COUNT(*)
- FROM wp_mepr_subscriptions AS s
- WHERE s.user_id=u.ID
- AND s.status='active'
- ) AS active_sub_count,
- (
- SELECT COUNT(*)
- FROM wp_mepr_subscriptions AS s
- WHERE s.user_id=u.ID
- AND s.status='suspended'
- ) AS suspended_sub_count,
- (
- SELECT COUNT(*)
- FROM wp_mepr_subscriptions AS s
- WHERE s.user_id=u.ID
- AND s.status='cancelled'
- ) AS cancelled_sub_count,
- (
- SELECT GROUP_CONCAT(
- DISTINCT t.product_id
- ORDER BY t.product_id
- SEPARATOR ','
- )
- FROM wp_mepr_transactions AS t
- WHERE t.user_id = u.ID
- AND (
- t.expires_at > '2019-07-19 10:52:46'
- OR t.expires_at = '0000-00-00 00:00:00'
- OR t.expires_at IS NULL
- )
- AND ( (
- t.txn_type IN ('payment','sub_account','fallback')
- AND t.status='complete'
- ) OR (
- t.txn_type='subscription_confirmation'
- AND t.status='confirmed'
- )
- )
- ) AS memberships,
- (
- SELECT e.id
- FROM wp_mepr_events AS e
- WHERE e.evt_id=u.ID
- AND e.evt_id_type='users'
- AND e.event='login'
- ORDER BY e.created_at DESC
- LIMIT 1
- ) AS last_login_id,
- (
- SELECT COUNT(*)
- FROM wp_mepr_events AS e
- WHERE e.evt_id=u.ID
- AND e.evt_id_type='users'
- AND e.event='login'
- ) AS login_count,
- (
- SELECT sum(t.total)
- FROM wp_mepr_transactions AS t
- WHERE t.user_id=u.ID
- AND t.status IN ('complete','confirmed')
- ) AS total_spent,
- '2019-07-19 10:52:46' AS updated_at
- FROM wp_users AS u
- WHERE u.ID = 272611
- LIMIT 1 | 0.000 |
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement