Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeOur CommunityOur CommunityGeneral Discuss...General Discuss...SQL StatementSQL Statement
Previous
 
Next
New Post
5/24/2006 5:45 AM
 
Hey Guys,

We are using SQLGRid module so we can display some user information. I have limited SQL knowledge and wondering if someone can help me with a statement. We are using DNN 3.2.

We are wanting to display all the Contact and Mailing information for all those who are part of the Registered Users role, but not part of the "Customer User Role" that we created. Basically we have a whole lot of members that are "registered", however have not paid subscriptions to joint the customer role we created. We now wanted to contact all these users.

Regards, Jay
 
New Post
5/24/2006 6:40 AM
 
Hi Jay

Have you had a look at the Simple SQL page on Smart-Thinker?
It may give you some ideas:

http://www.smart-thinker.com/DotNetNuke/Resources/SimpleSQL/tabid/267/Default.aspx

Entrepreneur

PokerDIY Tournament Manager - PokerDIY Tournament Manager<
PokerDIY Game Finder - Mobile Apps powered by DNN
PokerDIY - Connecting Poker Players

 
New Post
5/24/2006 7:17 AM
 
Thanks Rodney, that site is great. The one closest is this statement, but I just need to say "but not R.Rolename = "MyCustomerRole"

SELECT U.Username, U.Firstname, U.Lastname, R.Rolename, AM.Email
FROM Users U
INNER JOIN UserRoles UR on U.Userid = UR.Userid
INNER JOIN Roles R on UR.Roleid = R.Roleid
INNER JOIN Aspnet_users AU on U.Username = AU.Username
INNER JOIN Aspnet_membership AM on AU.Userid = AM.Userid
WHERE R.Rolename = 'Registered Users'
ORDER by U.Lastname

Cheers, Jay
 
New Post
5/24/2006 9:07 AM
 
Try this one:
SELECT U.Username, U.Firstname, U.Lastname, R.Rolename, AM.Email
FROM Users U
INNER JOIN UserRoles UR on U.Userid = UR.Userid
INNER JOIN Roles R on UR.Roleid = R.Roleid
INNER JOIN Aspnet_users AU on U.Username = AU.Username
INNER JOIN Aspnet_membership AM on AU.Userid = AM.Userid
WHERE R.Rolename = 'Registered Users' AND
R.RoleName <> 'MyCustomerRole'
ORDER by U.Lastname

Bryan Johns
K4GDW

"There are 10 types of people. Those who understand binary and those who do not."
 
New Post
5/24/2006 9:50 AM
 
Uhhh... My blood to coffee ratio must not have been high enough yet when I wrote that.  I don't think that query will work since a user can be in more than one role.  R.RoleName can only have one value for any given row of data.  So if R.RoleName = 'Registered Users' it obviously <> 'MyCustomerRole'.  Perhaps we need a corelated sub-query in the where clause.  Something like this:

SELECT U.Username, U.Firstname, U.Lastname, R.Rolename, AM.Email
FROM Users U
INNER JOIN UserRoles UR on U.Userid = UR.Userid
INNER JOIN Roles R on UR.Roleid = R.Roleid
INNER JOIN Aspnet_users AU on U.Username = AU.Username
INNER JOIN Aspnet_membership AM on AU.Userid = AM.Userid
WHERE R.Rolename = 'Registered Users' AND
U.Username NOT IN (
<select statement to get the usernames of all users in the MyCustomerRole role>
)
ORDER by U.Lastname
If no one else beats me to it I'll work it up tonight when I get home.  My boss is looking over my shoulder tapping his foot.  Just kidding.  He's not even here yet but since I'm at work I've already spent too much time doing non-work related stuff.

Bryan Johns
K4GDW

"There are 10 types of people. Those who understand binary and those who do not."
 
Previous
 
Next
HomeHomeOur CommunityOur CommunityGeneral Discuss...General Discuss...SQL StatementSQL Statement


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out