sql中as的用法和一些經(jīng)典的sql語句

sql中as的用法和一些經(jīng)典的sql語句

ID:8804934

大?。?3.00 KB

頁數(shù):3頁

時(shí)間:2018-04-08

sql中as的用法和一些經(jīng)典的sql語句_第1頁
sql中as的用法和一些經(jīng)典的sql語句_第2頁
sql中as的用法和一些經(jīng)典的sql語句_第3頁
資源描述:

《sql中as的用法和一些經(jīng)典的sql語句》由會員上傳分享,免費(fèi)在線閱讀,更多相關(guān)內(nèi)容在應(yīng)用文檔-天天文庫

1、sql中as的用法和一些經(jīng)典的sql語句2008-08-2121:55總結(jié)一些工作中用到或碰到的SQL語句,希望能與大家分享,同時(shí)也希望大家能提供更多的精妙SQL語句.....1、deletetable1from(selectfromtable2)ast2wheretable1.id=t2.id2、truncatetabletable1(不在事務(wù)日志中做記錄,比deletetable快,但不能激活觸發(fā)器)3、updatetable1setcolumn=column+1whereid=(selectidfromtable2)4、updatetable1setcolumn=column+

2、1fromtable1,table2wheretable1.id=table2.id5、selecttopn[Percent]fromtable1'輸出百分比記錄6、selectid,column1column2ascolumnfromtable1'可算明白as的用法了7、selectfromtable1wherecolumn1like'SQL#_G_O'escape'#''單匹配8、selecttable1.idfromtable1wherenotexists(selecttable2.idfromtable2wheretable1.id=table2.id)'這個(gè)應(yīng)該比notin

3、快一些9、selecttable1.idfromtable1,table2wheretable1.id<>table2.id'看復(fù)合查詢機(jī)制10、selecttable1.idfromtable1,table2,(selectidfromtable3)ast3wheretable1.id=table2.idandtable2.id=t3.id'有些類似[1]了......11、selectfromtable1wherecolumn1like'[A]%'orlike'[^B]%'12、select@column1=column1fromtable1;select@column1asco

4、lumn1'存儲到自定義變量13、selectfromtable1wherecontains(column1,'char1orchar2')'全文索引14、selectfromtable1wherecontains(column1,'前有near中有near后有')15、selectfromtable1wherecontains(column1,'formsof(inflectional,go)')'派生16、selectfromtable1wherecontains(description,'isabout(appleweight(.9),boyweight(.8),chinawe

5、ight(.7))')'權(quán)重17、selectfromtable1wherefreetext(column1,'char')'僅支持文字不支持表達(dá)式搜索18、insertintotable1selectcolumn1,count(column1)fromtable2groupbycolumn1'統(tǒng)計(jì)-----------------------------------------------------------------------------------------1說明:復(fù)制表(只復(fù)制結(jié)構(gòu),源表名:a新表名:b)SQL:selectintobfromawhere1<>12說

6、明:拷貝表(拷貝數(shù)據(jù),源表名:a目標(biāo)表名:b)SQL:insertintob(a,b,c)selectd,e,ffromb;3說明:顯示文章、提交人和最后回復(fù)時(shí)間SQL:selecta.title,a.username,b.adddatefromtablea,(selectmax(adddate)adddatefromtablewheretable.title=a.title)b4說明:外連接查詢(表名1:a表名2:b)SQL:selecta.a,a.b,a.c,b.c,b.d,b.ffromaLEFTOUTJOINbONa.a=b.c5說明:日程安排提前五分鐘提醒SQL:???se

7、lectfrom日程安排wheredatediff('minute',f開始時(shí)間,getdate())>56說明:兩張關(guān)聯(lián)表,刪除主表中已經(jīng)在副表中沒有的信息SQL:??deletefrominfowherenotexists(selectfrominfobzwhereinfo.infid=infobz.infid)7說明:從數(shù)據(jù)庫中去一年的各單位電話費(fèi)統(tǒng)計(jì)(電話費(fèi)定額和電話費(fèi)清單兩個(gè)表來源)SQL:SELECTa.userper,a.tel,a.stan

當(dāng)前文檔最多預(yù)覽五頁,下載文檔查看全文

此文檔下載收益歸作者所有

當(dāng)前文檔最多預(yù)覽五頁,下載文檔查看全文
溫馨提示:
1. 部分包含數(shù)學(xué)公式或PPT動(dòng)畫的文件,查看預(yù)覽時(shí)可能會顯示錯(cuò)亂或異常,文件下載后無此問題,請放心下載。
2. 本文檔由用戶上傳,版權(quán)歸屬用戶,天天文庫負(fù)責(zé)整理代發(fā)布。如果您對本文檔版權(quán)有爭議請及時(shí)聯(lián)系客服。
3. 下載前請仔細(xì)閱讀文檔內(nèi)容,確認(rèn)文檔內(nèi)容符合您的需求后進(jìn)行下載,若出現(xiàn)內(nèi)容與標(biāo)題不符可向本站投訴處理。
4. 下載文檔時(shí)可能由于網(wǎng)絡(luò)波動(dòng)等原因無法下載或下載錯(cuò)誤,付費(fèi)完成后未能成功下載的用戶請聯(lián)系客服處理。