Click here to Skip to main content
14,695,620 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
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
Comments
faisal23 20-Nov-12 6:56am
   
Try simple count query......

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
   
v2
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.
   
Comments
Jasbeer Singh 20-Nov-12 7:13am
   
i did it already , but how can i retrieve this count in a label.
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..
   
v2

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




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900