(1)模糊查詢:
select * from customers
where customername like 'a_% '
@.針對的是字元串 ''
@.必須使用like
@.通配符 % 、_ 、[]-->指其中的任一個字元
[abc]-->指abc中的任一個字母
[a-k]-->指a到k裡的任一個字母
[^a-k]-->指除a-k外的任一個字母
(2)子查詢 可放在select和where中...
例:判斷是否有相同的學号:
select count(*) ,xh from student
group by xh
having count(*)>1 or count(3)=2
@按子查詢傳回的結果分類------對應的方法
A口(一行一列)---- 直接取值
B目(多行一列)---- 比較列清單 in、>all、<all、>any、<any
C田(多行多列)----- 測試存在 exist()邏輯函數 傳回的一個值true/false
>all ==>大于後面表的最大值
<all ==>小于後面表的最小值
>any ==>大于後面表的最小值
<any ==>小于後面表的最大值
@把查詢的資料插入到一張新表中
select * into newtable from table1
@把資料寫到存在的表中
insert into table1 select * from table2
@建立表結構
select * into table1 from table2 where 1=2