基礎查詢
// 語法
select 查詢列表 from 表名;
/**1、查詢列表可以是: 表中的字段、常量值、表示式、函式
*2、查詢的結果是乙個虛擬的**
*///# 查詢單個字段
select
error_code
from error_log;
//# 查詢多個字段
select
error_name
,thread_id
from error_log;
//# 查詢所有字段
select
*from error_log;
//# 查詢常量
select1;
select
'mike'
;//# 查詢表示式
select
100/2;
select
100%98;
//# 查詢函式
select
version()
;//# 取別名
//# 方式一:使用 as
select
100%
98as reg;
select
thread_id
asid
,error_code
ascode
from error_log;
//# 方式二:使用空格
select
thread_idid,
error_code
code
from error_log;
//# 另外針對 out put 這中帶特殊字元(空格、逗號等等)的別名 需要使用雙引號包裹,
select
thread_id
"out put"
from error_log;
/** mysql 中 + 的作用僅僅只有乙個功能: 運算子
* select 100+90; 兩個運算元都為數值型,則做加法運算
* select '123'+23; 只要其中一方為字元型,試圖將字元型數值轉成數值型
* 如果轉換成功,則繼續做加法運算
* select 'john'+90; 如果轉換失敗,則將字串數值轉換成 0
* select null+10; 只要其中一方為 null,則結果肯定為 null
*///# 拼接 使用函式 concat,注意如果拼接的字段有乙個值為 null 則拼接結果為 null
// 案例:拼接欄位用逗號隔開
select
concat
(thread_id
,','
,error_code
)as reg from error_log;
MySQL 筆記2 MySQL 基礎
mysql 系列筆記是筆者學習 實踐mysql資料庫的筆記 mysql 資料庫基礎入門教程 mysql 官方文件 儲存引擎 儲存資料的技術。mysql中的資料可以用各種不同的技術儲存在檔案 或者記憶體 中,這些技術中的每一種技術都使用不同的儲存機制 索引技巧 鎖定水平並且最終提供廣泛的不同的功能和能...
MySQL基礎學習(2)查詢
基礎查詢 語法 select 查詢列表 from 表名 特點 1 查詢列表可以是 表中的字段 常量值 表示式 函式 2 查詢結果是乙個虛擬的 1.查詢表中的單個字段 select last name from employees 2.查詢表中的多個字段 select last name,salary...
(五 2)Mysql的基本查詢語句
一 查詢select 語法 select 列名稱 from 表名稱 其中 代表選擇顯示全部的列 1 無條件查詢 select from zhprny 即 查詢zhprny這個表中的所有列2 帶條件查詢 語法 select 列名稱 from 表名稱 where 列 運算子 值 運算子有 like be...