一位管理员下的用户数 [英] Count of Users under one admin
问题描述
你好,
我怎样才能得到一个管理员下的用户总数.我已经在一个表中以不同管理员的身份添加了各种用户.
我想在他的页面上显示每个管理员,他添加了多少用户.我想在管理员主页上的标签中获得该特定管理员下的用户总数.
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.
推荐答案
如果要查看所有管理员使用下的所有用户数这个
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;
如果您希望在单一管理员下显示用户列表,则需要重新整理您的SQL基础知识.有史以来最简单的查询.
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'
确保您没有复制整个代码,但是提供了正确的colom和表名
Make sure that your are not copy the entirecode, but along with that provide correct colom and table name
,如果您不了解数据库结构的更多信息,它将类似于:
Without knowing a lot more about your database structure, it will be something like:
SELECT COUNT(Users) FROM MyTable WHERE Admin='MyAdmin'
其中Users
和Admin
是表中的列.
尝试使用多个表执行此操作,例如SuperAdminTable具有所有AdminTable的外键,而这些表将具有UsersTable的外键.关系概念..
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..
这篇关于一位管理员下的用户数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!