我正在使用mysql,我想在我的数据库中找到最常见的电子邮件后缀。Sql代码列出数据库中最常见的电子邮件后缀
Example Dataset:
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
我想要的输出:
gmail.com - 3
yahoo.com - 2
hotmail.com - 1
aol.com - 1
我的第一直觉就是运行SQL命令,然后"SELECT userEmail FROM email_user_testing"
运行一个循环和操作与PHP的数据,但我有一种感觉它会使用sql命令更有效率。
+1:很好!从来不知道有关subtring_index :) – MatBailie 2011-02-25 18:56:11