將 ASCII() 函數與 WHERE 子句一起使用時,其傳回的輸出將取決於 WHERE 子句中給出的條件。例如,假設我們有一個名為「學生」的表,我們想要取得學生姓名的第一個字元的大於 65 的數字代碼。對此的查詢可以寫成如下 -
mysql> Select * from student; +------+---------+---------+-----------+ | Id | Name | Address | Subject | +------+---------+---------+-----------+ | 1 | Gaurav | Delhi | Computers | | 2 | Aarav | Mumbai | History | | 15 | Harshit | Delhi | Commerce | | 20 | Gaurav | Jaipur | Computers | +------+---------+---------+-----------+ 4 rows in set (0.10 sec) mysql> Select Name, ASCII(Name) As 'ASCII VALUE OF 1st Character' From Student WHERE ASCII(Name)>65; +---------+------------------------------+ | Name | ASCII VALUE OF 1st Character | +---------+------------------------------+ | Gaurav | 71 | | Harshit | 72 | | Gaurav | 71 | +---------+------------------------------+ 3 rows in set (0.00 sec)
以上是我們如何將 ASCII() 函數與 MySQL WHERE 子句一起使用?的詳細內容。更多資訊請關注PHP中文網其他相關文章!