server| Function | Cursor This is the Netizen's question, I at that time gave out own solution, but did not think the middle has a little problem, discovered after oneself careful debugging, completely obtains the correct result, that Netizen already has the knot post. My code became chicken ribs, food tasteless, discard. But I think my code is really quite classic, so tidy up a bit, for everyone to appreciate. Problem:
Suppose the environment is as follows:
Table 1:id, NAME, QQ, PHONE,
Table data: 1 Qin Yun 10102800 13500000
2 on the road 10378 13600000
3 LEO 10000 13900000
Table 2:id, NAME, Machine time, admin,
Table data: 1 Qin Yun 2004-1-1 Li Dawei
2 Qin Yun 2005-1-1 Ma Teng
3 on the way to 2005-1-1 Ma Teng
4 Qin Yun 2005-1-1 Li Dawei
5 on the way 2005-1-1 Li Dawei
Implementation objective: Take a list of all people from table 1, take the number of machines and administrators from table 2.
On-Machine personnel list the number of computer administrators (each administrator on these several machines are listed)
Qin Yun 3 Li Dawei, MA, Li Dawei
On the way 2 Ma, Li Dawei
LEO 0
If it's not the manager's list, that's what I wrote.
SELECT table 1.NAME as name, COUNT (table 2.ID) as number of machines
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.