The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
Need MySQL Query Help
I am trying to find users who have had one subscription but not the other.
I am using this query to locate one of the subscription types: SELECT username FROM subscriptionlog LEFT JOIN user ON (user.userid = subscriptionlog.userid) WHERE subscriptionid = 6 AND status = 0 AND usergroupid = 2 Now out of this group I need to find ONLY the users who have NOT had subscriptionid = 1. Basically, if there userid exists in subscriptionlog more than once (indicating more than one subscription has existed for the user) I don't want the username returned. ONLY users who have had subscriptionid 6 and NOT 1. Any help would be greatly appreciated! |
#2
|
|||
|
|||
...
WHERE subscriptionid = 6 AND subscriptionid <> 1 AND status = 0 AND usergroupid =2 should do it. |
#3
|
|||
|
|||
Quote:
I need a query that checks for multiple entires (row) having the same userid and different subscriptionid's and not return a result for userid's that have more than one entry (row). |
#4
|
|||
|
|||
OPTION1: Do some code to achieve this. You will need to use the result of one query (and it's rowset) to produce the internal result of the other.
you can throw the recordid into the internal query from the external one - which will give you your results your after. some pseudocode (do not use example only): PHP Code:
OPTION 3: You could look at SELECT ... WHERE field IN(SELECT ... WHERE) queries. hope this helps. |
Thread Tools | |
Display Modes | |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|