Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在尝试根据性别是否为男孩在我的数据库中显示姓名。我目前正在尝试这个查询,但它似乎不起作用。
SELECT Name, COUNT(Name), Gender='Boy' AS totalNumber FROM finaldb GROUP BY Name, Gender ORDER BY COUNT(Name) DESC LIMIT 5
有什么建议么?
我认为Gender='Boy'是在错误的地方,把它放在 WHERE 之后
Gender='Boy'
SELECT Name, Gender, COUNT(Name) AS totalNumber FROM finaldb WHERE Gender='Boy' GROUP BY Name, Gender ORDER BY COUNT(Name) DESC LIMIT 5
一般阅读 WHERE 和 SQL 的好地方:
http://www.w3schools.com/sql/sql_where.asp