The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
Need a MySQL Query
I need a MySQL query to search for any members who are in my "Paid" usergroup (Usergroup ID 9) but have no active paid subscriptions (subscription id 1, 9 or 10, either status=0 or NULL)
I am currently using this query but need to run 3 versions of it to catch all the 3 different paid subscriptons. Code:
SELECT user.username FROM user JOIN subscriptionlog sl1 ON (user.userid = sl1.userid AND sl1.subscriptionid in (1) AND sl1.status = 0 AND user.usergroupid = 9) LEFT JOIN subscriptionlog sl2 ON (user.userid = sl2.userid AND sl2.subscriptionid in (9,10)) WHERE sl2.userid IS NULL Any help that can be provided would be greatly appreciated! |
#2
|
|||
|
|||
I don't have a real database to test this on, and I'm also not an sql expert, but maybe something like:
Code:
SELECT username FROM (SELECT user.username, SUM(IF (subscriptionlog.subscriptionid IN (1, 9, 10) AND subscriptionlog.status, 1, 0)) AS status_sum FROM user LEFT JOIN subscriptionlog ON (user.userid = subscriptionlog.userid) WHERE user.usergroupid = 9 GROUP BY user.userid) AS X WHERE status_sum = 0 |
2 благодарности(ей) от: | ||
Max Taxable, tbworld |
#3
|
|||
|
|||
Ok, that appears to have worked! I'll keep an eye on it and update if it didn't work but so far, so good!
Many, many thanks!!! |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|