如何使用mysql的函式幫助

2021-10-09 12:10:40 字數 1178 閱讀 4707

現有這樣一張學生表,學生的性別是布林值,但是查詢結果想要顯示為男女,而不是01,該如何寫查詢語句?

case 列名 when 值1 then 顯示1 when 值2 then 顯示2 else 顯示3 end

select stuname as 姓名,

case stu*** when

1then

'男'when

0then

'女'else

'未知'

endas 性別 from

`tb_student`

;

select stuname,floor(datediff(curdate(

),stubirth)

/365

)as 學生年齡 from

`tb_student`

;

由上可知,在做資料庫查詢的時候,有些時候並不能直接拿到想要的結果。

但是,如何知道mysql中有哪些函式並知道它的用法呢?

在linux中,進入mysql,使用?後面跟上想要查詢的內容

語句含義

mysql> ? functions

查詢所有的函式

mysql> ? control flow functions

查詢分支控制函式

mysql> ? if function

查詢if 函式的使用方法

查所有函式

查某類函式

查具體函式

最下面有使用例項,一看就會!

mysql幫助的使用

mysql contents you asked for help about help category contents for more information,type help where is one ofthe following categories account manageme...

如何使用pytho幫助函式和文件

python 幫助 toc 在查詢函式用法時遇到一些小問題,在此記錄,逐漸補充。參考部落格 python基礎31 help 來檢視幫助 在互動命令列下可查詢內建函式的詳細資訊 可用的檢視 help modules 檢視python所有的modules help modules yourstr 單看p...

vuex使用幫助函式

一 獲取呼叫vuex中的值 直熱門使用this.store不使用.mapgetters就可以不用import import from vuex 要用vuex裡的的值還要搞這個玩意 computed 放在計算屬性我就有乙個userinfo的計算屬性 這個計算屬性的getter依賴store.geett...