- 11月 01 週二 201110:56
[SQL語法] UNION 合併資料表
- 11月 01 週二 201108:42
[MSSQL] 時間函數
取時間變數 , 抓今天的變數來做查詢條件
a. 將今天轉成七碼 民國年月日 select @wDate = CONVERT (VARCHAR(7), GETDATE(),12 )+0890000 2007/4/16 =>960416 算出n天前的年月日 DECLARE @wDATE VarChar(7),@n int SET @n = 45 select @wDate = CONVERT (VARCHAR(7), GETDATE()-@n,12 )+0890000
- 11月 01 週二 201108:22
[SQL語法] 條件式 IN
'使用"in" 搜尋select * from xxx where 欄位1 in('xx1','xx2','xx3'.......)取代了select * from xxx where 欄位1='xx1' or 欄位1='xx2'........更好用的是可以配合使用次查詢select * from xxx where 欄位1 in(select 欄位1 from xxx2 where.....)
- 10月 31 週一 201113:10
[SQL語法] Replace函數
- 10月 31 週一 201113:05
[SQL語法] Create 資料表
Create 語法create database stuednt #建立一個新的資料庫建立一個新的資料表create table student (
id smallint not null auto_increment,
account varchar(12) binary not null,
name varchar(12) not null,
sex tinyint(1) default 0 ,
date datetime,
primary key(id)
)
- 10月 28 週五 201110:20
[SQL語法] Insert Into語法
Insert Into(新增記錄)
Insert Into 資料表 (欄位串列) Values (欄位串列值)
例如:
Insert Into StuData (no, name) Values (100, '幕之內一步')
- 10月 28 週五 201110:19
[SQL語法] Update語法
Update(更新記錄)
Update 資料表 Set 指定運算式 Where 條件式
例如:
Update StuData Set name= '鳴人'
- 10月 28 週五 201110:18
[SQL語法] Delete 語法
Delete(刪除記錄)
Delete From 資料表 Where 條件式
註:省去Where時,會清除所有記錄
例如:
Delete From StuData Where sex='男'
- 10月 28 週五 201110:14
[SQL語法] Select 語法
Query(查詢)
Select 欄位 From 資料表 [Where 條件式] [Order By 欄位 [Desc]] [Limit 開始位置, 顯示筆數]
- 10月 28 週五 201109:52
[SQL語法] Select搜尋條件
Select條件式的寫法
- 部份字元的比對
用Like關鍵字,例:Where address Like '台南%'
相反條件用Not Like - 兩者之間
用Between … And …,例:Where age Between 20 And 30 - 逐一條件值
欄位名稱 In (值1, 值2, …)
相反條件用Not In …
※連接條件式用