程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 數據庫知識 >> MYSQL數據庫 >> MySQL綜合教程 >> mysql查詢類型轉換

mysql查詢類型轉換

編輯:MySQL綜合教程

 mysql查詢類型轉換   在mysql查詢時最好不要發生類型轉換,如把varchar轉換成int  

mysql> explain select * from user where name=1\G

 

  //如果你確定name字段是整型就不要把它轉化成字符串,不加單引號
*************************** 1. row ***************************
           id: 1
  select_type: SIMPLE
        table: user
         type: ALL
possible_keys: index_name_password
          key: NULL
      key_len: NULL
          ref: NULL
         rows: 99727
        Extra: Using where
1 row in set (0.02 sec)


mysql> explain select * from user where name='1'\G

 

  //如果你確定name字段是字符串就不要把它轉化成整型,加單引號
*************************** 1. row ***************************
           id: 1
  select_type: SIMPLE
        table: user
         type: ref
possible_keys: index_name_password
          key: index_name_password
      key_len: 111
          ref: const
         rows: 1
        Extra: Using where
1 row in set (0.00 sec)

 


  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved