Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: SQLVB.NET
hello,
how can i get total number of users under one admin. i have added various users under different admins in a single table.
i want to show every admin on his page, how many users are added by him. i want to get total count of users under that particular admin in a label on admins homepage.
Posted 20-Nov-12 0:46am
Comments
faisal23 at 20-Nov-12 6:56am
   
Try simple count query......
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

If you want to see the count of all users under all admins use this
SELECT Admin, COUNT(username) as "Number of employees"
FROM Users
--WHERE salary>  25000 -- provide some appropriate where cluase
GROUP BY Admin;
 
if you wish to show list of users under single admin you need to brushup your SQL basics. the simplest query ever.
 
SELECT username
From Users
WHERE Admin = 'xyz'
 
Make sure that your are not copy the entirecode, but along with that provide correct colom and table name
  Permalink  
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Try to do this using multiple tables like SuperAdminTable have foreign key of all the AdminTable, which will have foreign key of UsersTable.. so achieve this using Relationship concept..
  Permalink  
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

Without knowing a lot more about your database structure, it will be something like:
SELECT COUNT(Users) FROM MyTable WHERE Admin='MyAdmin'
Where Users and Admin are columns in your table.
  Permalink  
Comments
Jasbeer Singh at 20-Nov-12 7:13am
   
i did it already , but how can i retrieve this count in a label.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Your Filters
Interested
Ignored
     
0 sanket saxena 335
1 Abhinav S 333
2 Sergey Alexandrovich Kryukov 275
3 OriginalGriff 235
4 CPallini 205
0 Sergey Alexandrovich Kryukov 8,497
1 OriginalGriff 4,850
2 Peter Leow 3,839
3 Maciej Los 3,535
4 Er. Puneet Goel 3,107


Advertise | Privacy | Mobile
Web03 | 2.8.140415.2 | Last Updated 20 Nov 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Use
Layout: fixed | fluid