mysql怎麼以英文單詞的首字母group by?

來源:互聯網
上載者:User
mysql如何以英文單詞的首字母group by???
有一欄位 內容都是英文,我如何以英文單詞的首字母group by這個欄位??
沒有頭緒,謝謝了!


------解決方案--------------------
select *, upper(left(englishword,1)) as c
from tablename
group by c
------解決方案--------------------
SELECT evalue
FROM tablename
GROUP BY left( upper(rtrim( ltrim( evalue ) )) , 1 )
------解決方案--------------------
SELECT substr(欄位內容,1,1) FROM tablename
GROUP BY substr(欄位內容,1,1) HAVING (加一些你自己需要的限制條件)
------------------------------------
可能我對你的問理解的不正確,請把問題說的略為詳細一些哈,謝謝!
其實這種問題,完全可以自己在去Google上面搜一下,那樣效率會更高一下。

------解決方案--------------------
mysql> select * from a;
+-----+------------+
| aid | title |
+-----+------------+
| 1 | csdn |
| 2 | csdn |
| 3 | 666 |
| 4 | 343 |
| 5 | (NU |
| 6 | 343 |
| 7 | fgh |
| 8 | 676 |
| 9 | csdn |
| 10 | csdn |
| 11 | aaa[A]abcd |
| 89 | sfsdfsaf |
+-----+------------+
12 rows in set (0.00 sec)

mysql> select * from a order by substring(lcase(title),1,1) ;
+-----+------------+
| aid | title |
+-----+------------+
| 5 | (NU |
| 4 | 343 |
| 6 | 343 |
| 3 | 666 |
| 8 | 676 |
| 11 | aaa[A]abcd |
| 1 | csdn |
| 2 | csdn |
| 9 | csdn |
| 10 | csdn |
| 7 | fgh |
| 89 | sfsdfsaf |
+-----+------------+
12 rows in set (0.01 sec)
  • 相關文章

    聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.