title: sql query for list of all users details in Membership
body: <p>I'm using .net Membership for user management, I I'd like to make a page for admin that lists all users details.</p>
  
  <p>The Membership system created tables in my sql database server and I'm trying to get all info by query but somehow the query returns nothing.</p>
  
  <p><strong>these are the relevant tables created in the server:</strong></p>
  
  <p><img src="https://i.stack.imgur.com/shGsG.jpg" alt="Membership"></p>
  
  <p><strong>I tried this query: (ms sql 2008)</strong></p>
  
  <pre><code>select u.UserName, m.Email, m.CreateDate, m.LastLoginDate, r.RoleName from dbo.aspnet_Users u, dbo.aspnet_Membership m, dbo.aspnet_UsersInRoles uir, aspnet_Roles r where (u.UserId=m.UserId) and (m.UserId=uir.UserId) and (uir.RoleId=r.RoleId)
  </code></pre>
  
  <p>but it returns nothing, but when I try:</p>
  
  <pre><code>select u.UserName, r.RoleName from dbo.aspnet_Users u, dbo.aspnet_UsersInRoles uir, aspnet_Roles r where (u.UserId=uir.UserId) and (uir.RoleId=r.RoleId)
  </code></pre>
  
  <p>It returns a table with the user name and role.
  I guess the problem is with the Membership table userID field but I don't know how to explain it really.</p>