常用的mysql查詢

2022-07-16 09:57:09 字數 1677 閱讀 7656

查詢中文匹配

select cooperator_name,business_manager_id from tbl_cooperator where  hex(business_manager_id) regexp "e[4-9][0-9a-f]"

查詢商戶名全是中文的資料。

select cooperator_name from tbl_cooperator_conf where cooperator_name not regexp "[0-9]|[a-z]|[a-z]"

參考:按照日期統計資料

select date_format(created_date,'%y-%m-%d') as time,sum(money) money from o_finance_detail where org_id = 1000 group by time

select date_format(created_date,'%y-%m') as time,sum(money) money from o_finance_detail where org_id = 1000 group by time

select date_format(created_date,'%y') as time,sum(money) money from o_finance_detail where org_id = 1000 group by time

select date_format(created_date,'%y-%u') as time,sum(money) money from o_finance_detail where org_id = 1000 group by time

date_format(date,format)

根據format字串格式化date值。下列修飾符可以被用在format字串中:

%m 月名字(january……december)

%w 星期名字(sunday……saturday)

%d 有英語字首的月份的日期(1st, 2nd, 3rd, 等等。)

%y 年, 數字, 4 位

%y 年, 數字, 2 位

%a 縮寫的星期名字(sun……sat)

%d 月份中的天數, 數字(00……31)

%e 月份中的天數, 數字(0……31)

%m 月, 數字(01……12)

%c 月, 數字(1……12)

%b 縮寫的月份名字(jan……dec)

%j 一年中的天數(001……366)

%h 小時(00……23)

%k 小時(0……23)

%h 小時(01……12)

%i 小時(01……12)

%l 小時(1……12)

%i 分鐘, 數字(00……59)

%r 時間,12 小時(hh:mm:ss [ap]m)

%t 時間,24 小時(hh:mm:ss)

%s 秒(00……59)

%s 秒(00……59)

%p am或pm

%w 乙個星期中的天數(0=sunday ……6=saturday )

%u 星期(0……52), 這裡星期天是星期的第一天

%u 星期(0……52), 這裡星期一是星期的第一天

%% 乙個文字「%」。

參考:

mysql常用的查詢 MySQL常用查詢

資料庫 1.查詢所有資料的大小 data length 資料大小 index length 索引大小 select concat round sum data length index length 1024 1024,2 mb as data from information schema.tab...

mysql常用的查詢 MySQL常用查詢

select from unixtime create time,y m as time,sum sales amount sales amount sum from sales group by time 執行結果如下 查詢每年的銷售額 select from unixtime create ti...

mysql 查詢 常用 mysql常用查詢

一.group concat函式,以指定的分割符合並列,與group by 一起用 例 selectgroup concat c.columnname separator group by 二.preparedstatement.return generated keys 得到剛剛插入記錄的id p...