|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
MySQL最初的开发者的意图是用mSQL和他们自己的快速低级例程(ISAM)去连接表格。经过一些测试后,开发者得出结论:mSQL并没有他们需要的那么快和灵活。语句申明:复制表(只复制布局,源表名:a新表名:b)SQL:select*intobfromawhere11申明:拷贝表(拷贝数据,源表名:a方针表名:b)SQL:insertintob(a,b,c)selectd,e,ffromb;申明:显现文章、提交人和最初复兴工夫SQL:selecta.title,a.username,b.adddatefromtablea,(selectmax(adddate)adddatefromtablewheretable.title=a.title)b申明:外毗连查询(表名1:a表名2:b)SQL:selecta.a,a.b,a.c,b.c,b.d,b.ffromaLEFTOUTJOINbONa.a=b.c申明:日程布置提早五分钟提示SQL:select*from日程布置wheredatediff(minute,f入手下手工夫,getdate())>5申明:两张联系关系表,删除主表中已在副表中没有的信息SQL:deletefrominfowherenotexists(select*frominfobzwhereinfo.infid=infobz.infid申明:--SQL:SELECTA.NUM,A.NAME,B.UPD_DATE,B.PREV_UPD_DATEFROMTABLE1,(SELECTX.NUM,X.UPD_DATE,Y.UPD_DATEPREV_UPD_DATEFROM(SELECTNUM,UPD_DATE,INBOUND_QTY,STOCK_ONHANDFROMTABLE2WHERETO_CHAR(UPD_DATE,YYYY/MM)=TO_CHAR(SYSDATE,YYYY/MM))X,(SELECTNUM,UPD_DATE,STOCK_ONHANDFROMTABLE2WHERETO_CHAR(UPD_DATE,YYYY/MM)=TO_CHAR(TO_DATE(TO_CHAR(SYSDATE,YYYY/MM)||/01,YYYY/MM/DD)-1,YYYY/MM)Y,WHEREX.NUM=Y.NUM(+)ANDX.INBOUND_QTY+NVL(Y.STOCK_ONHAND,0)X.STOCK_ONHANDBWHEREA.NUM=B.NUM申明:--SQL:select*fromstudentinfowherenotexists(select*fromstudentwherestudentinfo.id=student.id)and系称号="&strdepartmentname&"and专业称号="&strprofessionname&"orderby性别,生源地,高考总成就申明:从数据库中往一年的各单元德律风费统计(德律风费定额贺电化肥清单两个表来历)SQL:SELECTa.userper,a.tel,a.standfee,TO_CHAR(a.telfeedate,yyyy)AStelyear,SUM(decode(TO_CHAR(a.telfeedate,mm),01,a.factration))ASJAN,SUM(decode(TO_CHAR(a.telfeedate,mm),02,a.factration))ASFRI,SUM(decode(TO_CHAR(a.telfeedate,mm),03,a.factration))ASMAR,SUM(decode(TO_CHAR(a.telfeedate,mm),04,a.factration))ASAPR,SUM(decode(TO_CHAR(a.telfeedate,mm),05,a.factration))ASMAY,SUM(decode(TO_CHAR(a.telfeedate,mm),06,a.factration))ASJUE,SUM(decode(TO_CHAR(a.telfeedate,mm),07,a.factration))ASJUL,SUM(decode(TO_CHAR(a.telfeedate,mm),08,a.factration))ASAGU,SUM(decode(TO_CHAR(a.telfeedate,mm),09,a.factration))ASSEP,SUM(decode(TO_CHAR(a.telfeedate,mm),10,a.factration))ASOCT,SUM(decode(TO_CHAR(a.telfeedate,mm),11,a.factration))ASNOV,SUM(decode(TO_CHAR(a.telfeedate,mm),12,a.factration))ASDECFROM(SELECTa.userper,a.tel,a.standfee,b.telfeedate,b.factrationFROMTELFEESTANDa,TELFEEbWHEREa.tel=b.telfax)aGROUPBYa.userper,a.tel,a.standfee,TO_CHAR(a.telfeedate,yyyy)申明:四表联查询题:SQL:select*fromaleftinnerjoinbona.a=b.brightinnerjoincona.a=c.cinnerjoindona.a=d.dwhere.....申明:失掉表中最小的未利用的ID号SQL:SELECT(CASEWHENEXISTS(SELECT*FROMHandlebWHEREb.HandleID=1)THENMIN(HandleID)+1ELSE1END)asHandleIDFROMHandleWHERENOTHandleIDIN(SELECTa.HandleID-1FROMHandlea)两个到底是哪一个给出了MySQL这个名字至今依然是个迷,包括开发者在内也不知道。 |
|