MYSQL 進制轉換 [ CONV( N, from_base, to_base) ]

MYSQL 進制轉換 [ CONV( N, from_base, to_base) ]

MYSQL 進制轉換 [ CONV( N, from_base, to_base) ]

資料來源: http://pclevinblog.pixnet.net/blog/post/314563585-%5Bmysql%5D%EF%BC%88%E5%AD%97%E4%B8%B2%E6%95%B8%E5%AD%97%E8%BD%89%E6%8F%9B%E6%95%B4%E6%95%B8%E6%95%B8%E5%AD%97%EF%BC%89%E4%BD%BF%E7%94%A8conv%E5%87%BD%E6%95%B0

語法: 

CONV( N, from_base, to_base)

ex:[10->16]進制

SELECT cir.timestamp AS timestamp,cir.status AS status,rs.name AS n_status,cir.door_index AS door_index,CONV(cir.serial_number,10,16) AS serial_number,cir.card_unique_identifier AS card_unique_identifier FROM controller_io_record AS cir,record_status AS rs WHERE (cir.status=rs.id) AND (cir.card_unique_identifier='')

SELECT cir.timestamp AS timestamp,cir.status AS status,rs.name AS n_status,cir.door_index AS door_index,CONV(cir.serial_number,10,16) AS serial_number,cir.card_unique_identifier AS card_unique_identifier FROM controller_io_record AS cir,record_status AS rs WHERE (cir.status=rs.id) AND (cir.card_unique_identifier<>'')

One thought on “MYSQL 進制轉換 [ CONV( N, from_base, to_base) ]

  1. 2018/09/16
    base 70萬筆資料
    base
    SELECT cir.timestamp AS timestamp,cir.status AS status,cir.door_index AS door_index,CONV(cir.serial_number,10,16) AS serial_number,cir.card_unique_identifier AS card_unique_identifier FROM controller_io_record AS cir;
    欄位紀錄: 時間,狀態,控制器SN(16進位),卡號

    base 計算筆數
    SELECT COUNT(*) FROM (SELECT cir.timestamp AS timestamp,cir.status AS status,cir.door_index AS door_index,CONV(cir.serial_number,10,16) AS serial_number,cir.card_unique_identifier AS card_unique_identifier FROM controller_io_record AS cir) AS base; [0.6961S]

發表迴響

你的電子郵件位址並不會被公開。 必要欄位標記為 *