版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
1、mysql 開發(fā)者sql 權(quán)威指南sql for mysql developers a comprehensive tutorial and reference 整理:侯杰mysql 開發(fā)范例- 1 - 第一章 sql 概要1.引入一個(gè)名為 booksql 的新用戶,他的密碼是booksqlpw 。create user booksql localhost identified by booksqlpwcreate user houjie410782 localhost identified by 630529 2.給 sql 用戶 booksql 創(chuàng)建和操作表的權(quán)限。grant all pr
2、ivileges on *.* to booksql localhost with grant option; grat all privileges on *.* to houjie410782 localhost with grant option; 3.創(chuàng)建數(shù)據(jù)庫 tennis。create database tennis; 4.指定 tennis 為當(dāng)前數(shù)據(jù)庫。use tennis; 5.創(chuàng)建表 players ,teams,matches ,penalties ,committee_members 。create table players (playerno integer not
3、 null, name char(15) not null, initials char(3) not null, birth_date date, sex char(1) not null, joined smallint not null, street varchar(30) not null, houseno char(4), postcode char(6), town varchar(30) not null, phoneno char(13), leagueno char(4), primary key (playerno) ) create table teams( teamn
4、o integer not null, playerno integer not null, division char(6) not null, primary key (teamno) ) create table matches( matchno integer not null, teamno integer not null, playerno integer not null, won smallint not null, lost smallint not null, primary key (matchno) ) create table penalties( paymentn
5、o integer not null, playerno integer not null, payment_date date not null, amount decimal(7,2) not null, primary key (paymentno) mysql 開發(fā)范例- 2 - ) create table committee_members( playerno integer not null, begin_date date not null, end_date date, position char(20), primary key (playerno,begin_date)
6、) 6.為表中填充數(shù)據(jù)。insert into players values(2,everett,r,1948-09-01,m,1975,stoney road,43,3575nh,stratford,070-237893,2411); insert into players values(7,wise,gws,1963-05-11,m,1981,edgecombe way,39,9758vb,stratford,070-347689,null); insert into players values(8,newcastle,b,1962-07-08,f,1980,station road,4
7、,6584r0,inglewood,070-458458,2983); insert into players values(27,collins,dd,1964-12-28,f,1983,long drive,804,8457dk,eltham,079-234857,2513); insert into players values(28,collins,c,1963-06-22,f,1983,old mian road,10,1294qk,midhurst,071-659599,null); insert into players values(39,bishop,d,1956-10-29
8、,m,1980,eaton square,78,9629cd,stratford,070-393435,null); insert into players values(44,baker,e,1963-01-09,m,1980,lewis street,23,4444lj,inglewood,070-368753,1124); insert into players values(57,brown,m,1971-08-17,m,1985,edgecombe way,16,4377cb,stratford,070-473458,6409); insert into players values
9、(83,hope,pk,1956-11-11,m,1982,magdalene road,16a,1812up,stratford,070-353548,1608); insert into players values(95,miller,p,1963-05-14,m,1972,high street,33a,5746op,douglas,070-867564,null); insert into players values(100,parmanter,p,1963-02-28,m,1979,haseltine lane,80,1234kk,stratford,070-494593,652
10、4); insert into players values(104,moorman,d,1970-05-10,f,1984,stout street,65,9437a0,eltham,079-987571,7060); insert into players values(112,bailey,ip,1963-10-01,f,1984,vixen road,8,6392lk,plymouth,010-548745,1319); insert into players values(6,parmenter,r,1964-06-25,m,1977,haseltine lane,80,1234kk
11、,stratford,070-476537,8467); insert into teams values(1,6,first); insert into teams values(2,27,second); insert into matches values(1,1,6,3,1); insert into matches values(2,1,6,2,3); insert into matches values(3,1,6,3,0); insert into matches values(4,1,44,3,2); insert into matches values(5,1,83,0,3)
12、; insert into matches values(6,1,2,1,3); insert into matches values(7,1,2,1,3); insert into matches values(8,1,8,0,3); insert into matches values(9,2,27,3,2); mysql 開發(fā)范例- 3 - insert into matches values(10,2,104,3,2); insert into matches values(11,2,112,2,3); insert into matches values(12,2,112,1,3);
13、 insert into matches values(13,2,8,0,3); insert into penalties values(1,6,1980-12-08,100.00); insert into penalties values(2,44,1981-05-05,75.00); insert into penalties values(3,27,1983-09-10,100.00); insert into penalties values(4,104,1984-12-08,50.00); insert into penalties values(5,44,1980-12-08,
14、25.00); insert into penalties values(6,8,1980-12-08,25.00); insert into penalties values(7,44,1982-12-30,30.00); insert into penalties values(8,27,1984-11-12,75.00); insert into committee_members values(2,1990-01-01,1992-12-31,chairman); insert into committee_members values(2,1994-01-01,null,member)
15、; insert into committee_members values(6,1990-01-01,1990-12-31,secretary); insert into committee_members values(6,1991-01-01,1992-12-31,member); insert into committee_members values(6,1992-01-01,1993-12-31,treasurer); insert into committee_members values(6,1993-01-01,null,chairman); insert into comm
16、ittee_members values(8,1990-01-01,1990-12-31,treasurer); insert into committee_members values(8,1991-01-01,1991-12-31,secretary); insert into committee_members values(8,1993-01-01,1993-12-31,member); insert into committee_members values(8,1994-01-01,null,member); insert into committee_members values
17、(27,1990-01-01,1990-12-31,member); insert into committee_members values(27,1991-01-01,1991-12-31,treasurer); insert into committee_members values(27,1993-01-01,1993-12-31,treasurer); insert into committee_members values(57,1992-01-01,1992-12-31,secretary); insert into committee_members values(95,199
18、4-01-01,null,treasurer); insert into committee_members values(112,1992-01-01,1992-12-31,member); insert into committee_members values(112,1994-01-01,null,secretary); 7. 獲取居住在 stratford 的每個(gè)球員的號(hào)碼、名字和出生日期,按照名字的順序排列結(jié)果。select playerno,name,birth_date from players where town= stratford order by name; 8.獲取
19、在 1980 年后加入俱樂部并且居住在stratford 的每個(gè)球員號(hào)碼,按照球員號(hào)碼排序。select playerno from players where town= stratford and joined1980 order by playerno; 9.獲取有關(guān)罰款的所有信息。select * from penalties; 10.121 的 33 倍是多少?select 33*121; 11.獲取 44 號(hào)球員的罰款數(shù)額,并把該球員的金額該為200 美元。select playerno,amount from penalties where playerno=44; mysql
20、開發(fā)范例- 4 - update penalties set amount=200 where playerno=44; 12.刪除 penalties 表中罰款金額大于100 美元的每一筆罰款。delete from penalties where amount100; 13.在 penalties 表的 amount 列上創(chuàng)建一個(gè)索引。create index penalties_amount on penalties(amount); 14.創(chuàng)建一個(gè)視圖,記錄每場(chǎng)比賽贏得的局?jǐn)?shù)和輸?shù)舻木謹(jǐn)?shù)。create view number_sets(matchno,difference) as se
21、lece matchno,abs(win-lost) from matches; mysql 開發(fā)范例- 5 - 第二章 select語句:常用元素1.為一個(gè)特定的表添加一個(gè)不正確的日期并顯示結(jié)果。create table incorrect_date(column1 date); insert into incorrect_date values ( 2009-13-12 ); select column1 from incorrect_date; 2.對(duì)于贏得的局?jǐn)?shù)等于輸?shù)舻木謹(jǐn)?shù)加2 的每場(chǎng)比賽,獲得比賽號(hào)碼以及贏得的局?jǐn)?shù)和輸?shù)舻木謹(jǐn)?shù)之間的差值。select matchno,won-los
22、t as difference from matches where won-lost=2; 3.對(duì)于每個(gè)球隊(duì)得到編號(hào)和分級(jí)。select teamno,division from teams; 4.對(duì)于每個(gè)球隊(duì),獲得編號(hào)和分級(jí),并使用全名。select teamno as team_number,division as division_of_team from teams; 5.對(duì)于每次罰款,獲取支付編號(hào)和以分為單位的罰款數(shù)額。select paymentno,amount*100 as cents from penalties; 6.從 matches 表中獲得一些數(shù)據(jù)。select m
23、atchno as primarykey,80 as eighty, won-lost as difference,time(23:59:59) as almost_midnight,text as text from matches where matchno6; 9.創(chuàng)建用戶變量 playerno ,并用 7 來初始化它。set playerno=7; 10.獲取球員號(hào)碼小于已經(jīng)創(chuàng)建的用戶變量playerno 的值的所有球員的姓,居住城市也郵政編碼。select ,town,postcode from players where playerno1980; 16.在
24、一條 select 語句中嵌套使用 case。select playerno,town,birth_date, case town when stratford then st when plymouth then pm when inglewood then iw else ot end as position, case town when stratford then case birth_date when 1948-09-01 then old stratford else young stratford end when inglewood then case birth_date
25、 when 1962-07-08 then old ingelwood else young inglewood end else rest end as type from players; 17.對(duì)每個(gè)球員找到球員號(hào)碼,他加入俱樂部的年份和球員的年齡組。select playerno,joined, case when joined1980 then senior when joined=1980 and joined1983 then senior when town= eltham then elthammers mysql 開發(fā)范例- 7 - when playerno1980; 2
26、0.對(duì)于姓氏以大寫字母b 開頭的每個(gè)球員,獲取其號(hào)碼以及名字的首字母,隨后跟一個(gè)小數(shù)點(diǎn)和姓。select playerno,concat(left(initials,1), . ,name) as full_name from players where left(name,1)= b ; 21.對(duì)于居住在 stratford 的每個(gè)球員,獲取其名字, 姓氏和聯(lián)盟會(huì)員號(hào)碼, 如果聯(lián)盟會(huì)員號(hào)碼為空,將其顯示為 1。select initials,name,coalesce(leagueno, 1 ) as league from players where town= stratford ; 注
27、意: coalesce(leagueno, 1 )的意思是:如果 leagueno 非空,就取當(dāng)前 leagueno ,否則取 1. 22.對(duì)于所有號(hào)碼小于 10 的球員,獲取球員號(hào)碼, 他們出生的那天是星期幾, 他們出生所在的月份以及他們出生那天是該年的多少天。select playerno,dayname(birth_date),monthname(birth_date),dayofyear(birth_date) from players where playerno500 or(end_date is null and datediff(current_date,begin_date)
28、500) order by playerno; 或者這樣寫:select playerno,begin_date,end_date, datediff(coalesce(end_date,current_date),begin_date) as diff from committee_members where datediff(coalesce(end_date,current_date),begin_date)500 order by playerno; 25.對(duì)于每一筆大于 50 的罰款,獲取支付編號(hào)。select paymentno from penalties where amoun
29、t50; 26.對(duì)于居住在 inglewood 的每個(gè)球員,獲取他們的名字和生日作為一個(gè)完整的字符值。select concat(rtrim(name),cast(birth_date as char(10) from players where town= inglewood ; 27.把編號(hào)為 2 的球員的聯(lián)盟會(huì)員號(hào)碼改為空值。update players mysql 開發(fā)范例- 8 - set leagueno=null where playerno=2; 28.對(duì)于每個(gè)球隊(duì),獲取球隊(duì)號(hào)碼,后面跟著一個(gè)空值。select teamno,cast(null as char) from te
30、ams; 29.對(duì)于勝出局?jǐn)?shù)大于或等于輸?shù)舻木謹(jǐn)?shù)乘以2 的每場(chǎng)比賽, 獲得比賽號(hào)碼, 勝出局?jǐn)?shù)和輸?shù)艟謹(jǐn)?shù)。select matchno,won,lost from matches where won=lost*2; 30.把 50 左移 2 位。select 502; 31.把二進(jìn)制的 11 向左移動(dòng)三位。select b 11 1)5; 或者這樣寫:select paymentno,payment_date, adddate(payment_date,interval 7 day) as add7days from penalties where paymentno5; 39.獲取在 198
31、2 年圣誕節(jié)( 12 月 25 日)以及新年前夕支付的罰款。select paymentno,payment_date from penalties where payment_date= 1982-12-25 and payment_dateadddate( 1982-12-25 ,interval 7 day); mysql 開發(fā)范例- 9 - 40.在日期直接量 2004-13-12 上增加一天,接下來顯示錯(cuò)誤信息。select adddate( 2004-13-12 ,interval 1 day); show warnings; 41.創(chuàng)建一個(gè) matches 表的特殊形式 matc
32、hes_special, 其中包含比賽進(jìn)行的日期,開始時(shí)間和結(jié)束時(shí)間。create table matches_special( matchno integer not null, teamno integer not null, playerno integer not null, won smallint not null, lost smallint not null, start_date date not null, start_time time not null, end_date date not null, end_time time not null, primary ke
33、y(matchno) 插入兩組數(shù)據(jù):insert into match_special values(1,1,6,3,1, 2004-10-25 , 14:10:12 , 2004-10-25 , 16:50:09 ); insert into match_special values(2,1,44,3,2, 2004-10-29 , 08:30:00 , 2004-10-25 , 10:00:00 ); 42.對(duì)于每場(chǎng)比賽,獲取其開始時(shí)間,并獲取開始時(shí)間加上8 小時(shí)候的時(shí)間。select matchno,start_time,addtime(start_time, 08:00:00 ) fr
34、om match_special; 43.獲得至少在午夜前 6.5 小時(shí)結(jié)束的比賽。select matchno,end_time from match_special where addtime(end_time, 06:30:30 )4 from penalties; 47.找出下面兩個(gè)條件都滿足或都不滿足的球員,球員的號(hào)碼小于15, 加入俱樂部的年份晚于1979年。select playerno,joined,playerno1979 from players where (playerno1979); 48.(行表達(dá)式 )為 committee_members表添加一個(gè)新行。inser
35、t into committee_members values(7+15,current_date,current_date+interval 17 day, member ); 49.獲取居住在 stratford 的 haseltine lane 的球員號(hào)碼和名字。select playerno from players where (town,street)=( stratford , haseltine lane ); 50.找到那些居住在 stratford 的 haseltine lane 的所有球員號(hào)碼和名字。mysql 開發(fā)范例- 10 - select playerno,na
36、me from players where (town,street)=(select stratford , haseltine lane ); 答案通 49 題。mysql 開發(fā)范例- 11 - 第三章 select語句、表表達(dá)式和子查詢1.找到至少引發(fā)兩次多余25 美元的罰款的每個(gè)球員號(hào)碼,根據(jù)球員號(hào)碼對(duì)結(jié)果排序。select playerno from players,penalties where amount25 having count(*)1 order by playerno; 2.獲得居住在 stratford 的每個(gè)球員的號(hào)碼和聯(lián)盟會(huì)員號(hào)碼,根據(jù)聯(lián)盟號(hào)碼排序。select
37、 playerno,leagueno from players where town= stratford order by leagueno; 3.獲取球隊(duì)隊(duì)長(zhǎng)的號(hào)碼以及引發(fā)罰款的球員號(hào)碼。select playerno from teams union select playerno from penalties; 4.獲得編號(hào)小于 10 的男性球員號(hào)碼。select playerno from(select playerno,sex from players where playerno10) as greater10 where playerno1980) as joined1980
38、where sex= m ; 以上語句同:select playerno from players where playerno10 and joined1980 and sex= m ; 6.對(duì)于號(hào)碼小于 60 的每個(gè)球員,獲取他們加入俱樂部的年份和100 號(hào)球員加入俱樂部年份之間的差值。select playerno,joined- (select joined from players where playerno=100) as diff_100 from players where playerno60; 7.獲取和 27 號(hào)球員出生于同一年的球員號(hào)碼。select playerno
39、 from players mysql 開發(fā)范例- 12 - where year(birth_date)=(select year(birth_date) from players where playerno=27); 8.獲取 27 號(hào)球員、 44 號(hào)球員和 100 號(hào)球員的生日作為一行。select (select birth_date from players where playerno=27), (select birth_date from players where playerno=44), (select birth_date from players where pla
40、yerno=100); 9.獲取與 100 號(hào)球員性別相同且居住在同一城市的球員號(hào)碼。select playerno from players where (sex,town)=(select sex,town from players where playerno=100); mysql 開發(fā)范例- 13 - 第四章 select子句: from 子句1.創(chuàng)建一個(gè)數(shù)據(jù)庫 extra,并創(chuàng)建一個(gè) cities 表,插入兩行數(shù)據(jù)。create database extra; use extra; create table cities(cityno integer not null, cityn
41、ame char(20) not null, primary key(cityno); insert into cities values(1, stratford ); insert into cities values(2, inglewood ); 2.在當(dāng)前數(shù)據(jù)庫為 tennis 的前提下,訪問 extra 數(shù)據(jù)庫的 cities 列。select * from extra.cities; 同理,在當(dāng)前數(shù)據(jù)庫為extra 的情況下,也可以范圍tennis 數(shù)據(jù)庫里的所有內(nèi)容。3.獲取球隊(duì)編號(hào)和每個(gè)球隊(duì)隊(duì)長(zhǎng)的名字。select teamno,name from teams,players
42、 where teams.playerno=players.playerno; 4.對(duì)每一筆罰款,找出支付編號(hào),罰款數(shù)額以及引起罰款的球員號(hào)碼,名字和首字母。select players.playerno,,players.initials, penalties.paymentno,penalties.amount from players,penalties where players.playerno=penalties.playerno; 5.(使用假名) 對(duì)于每一筆罰款, 獲得支付編號(hào), 罰款數(shù)額,引發(fā)罰款球員的號(hào)碼, 名字和首字母。select pen.pay
43、mentno,pen.amount,p.playerno,,p.initials from players as p,penalties as pen where p.playerno=pen.playerno; 6.獲取至少引起一次罰款的隊(duì)長(zhǎng)號(hào)碼。select t.playerno from teams as t,penalties as pen where t.playerno=pen.playerno; 7.獲取至少引起一次罰款的隊(duì)長(zhǎng)號(hào)碼,刪除重復(fù)的號(hào)碼。select distinct t.playerno from teams as t,penalties as pen w
44、here t.playerno=pen.playerno; 8.獲取至少參加了一場(chǎng)比賽的球員名字和首字母,注意,一個(gè)球員不一定必須出現(xiàn)在matches 表中(他可能整個(gè)賽季都因傷缺席)select distinct ,p.initials from players as p,matches as m where p.playerno=m.playerno; 9.對(duì)于每一場(chǎng)比賽,獲取比賽編號(hào),球員代號(hào),球隊(duì)編號(hào),球員名字以及參加的球隊(duì)分級(jí)。select m.matchno,p.playerno,m.teamno,,t.division from matches as m,
45、players as p,teams as t where p.playerno=m.playerno and t.teamno=m.teamno; 10.對(duì)于球員加入俱樂部當(dāng)年所引起的每一筆罰款,獲得支付編號(hào),球員號(hào)碼以及支付日期。select pen.paymentno,p.playerno,pen.payment_date from players as p,penalties as pen where pen.playerno=p.playerno and year(pen.payment_date)=p.joined; 11.(必須使用假名的情況)獲取比r.parmenter 年齡大
46、的每個(gè)球員的號(hào)碼,在這個(gè)例子中,假設(shè)名字和首字母的組合是唯一的。mysql 開發(fā)范例- 14 - select p.playerno from players as p,players as par where =parmenter and par.initials=r and p.birth_date1920-06-30; 顯示表示為:select p.playerno,name,pen.amount from players as p inner join penalties as pen on(p.playerno=pen.playerno) where p.birth_
47、date1920-06-30; 14.對(duì)于每個(gè)球隊(duì),找出球隊(duì)的號(hào)碼和隊(duì)長(zhǎng)的名字,分別用隱式表示和顯示表示。隱式:select t.teamno, from teams as t,players as p where t.playerno=p.playerno; 顯示:select t.teamno, from teams as t inner join players as p on(t.playerno=p.playerno); 15.(左外連接)對(duì)于 所有球員 ,獲得球員號(hào)碼,名字和他所引起的罰款,結(jié)果按照球員號(hào)碼排序。按照一般的寫法是這樣的:select p.pl
48、ayerno,name,pen.amount from players as p,penalties as pen where p.playerno=pen.playerno order by p.playerno; 但是這樣的寫法是不完整的,為了強(qiáng)調(diào)所有球員 ,應(yīng)當(dāng)使用左外連接:select p.playerno,name,pen.amount from players as p left outer join penalties as pen on p.playerno=pen.playerno order by p.playerno; 對(duì)于所有外連接, outer 關(guān)鍵字可以省略,最終結(jié)
49、果不會(huì)受任何影響。左外連接是否必要,取決于問題和連接之間的關(guān)系,在p.playerno 和 pen.playerno 之間,存在一個(gè)子集關(guān)系,因此,左外連接是有用的。16.對(duì)于每一筆罰款,獲取支付編號(hào)和球員名字。select pen.paymentno, from penalties as pen left outer join players as p on pen.playerno=p.playerno order by pen.paymentno; 在此例中, penalties 在一個(gè)左表,由于沒有那一筆罰款不是助于一個(gè)球員的,因此沒有一筆罰款是漏掉的,左外連接不起作用,使
50、用內(nèi)連接也會(huì)得到相同的結(jié)果。17.對(duì)于每個(gè)球員 ,獲得球員編號(hào)和名字以及他當(dāng)隊(duì)長(zhǎng)的球隊(duì)的編號(hào)和分級(jí),按照球員編號(hào)排序。select p.playerno,name,t.teamno,t.division from players as p left outer join teams as t on p.playerno=t.playerno mysql 開發(fā)范例- 15 - order by p.playerno; 18.對(duì)于居住在 inglewood 的每個(gè)球員 ,獲取球員編號(hào),名字,罰款列表并且列出他曾經(jīng)效力過的球隊(duì)。select p.playerno,,pen.amount,
51、m.teamno from players as p left outer join penalties as pen on p.playerno=pen.playerno left outer join matches as m on p.playerno=m.playerno where p.town=inglewood; 19.(右外連接)對(duì)于 所有球員 ,獲取球員號(hào)碼,名字和他們當(dāng)隊(duì)長(zhǎng)的球隊(duì)編號(hào)。select p.playerno,,t.teamno from teams as t right outer join players as p on t.playerno=p.
52、playerno; 20.(自然連接) 對(duì)于出生于 1920-06-30 后且至少一次罰款的每個(gè)球員,獲得球員號(hào)碼名字和所有罰款。一般情況下我們會(huì)這樣寫:select p.playerno,,pen.amount from players as p,penalties as pen where p.playerno=pen.playerno and p.birth_date1020-06-30; 使用自然連接后,語句就縮短了:select p.playerno,,pen.amount from players as p natural join penalties as
53、 pen where p.birth_date1920-06-30; 21.(連接條件中的附加條件)下一條select 語句包含了一個(gè)左外連接加上where 子句的一個(gè)附加條件。select teams.playerno,teams.teamno,penalties.patmentno from teams left outer join penalties on teams.playerno=penalties.playerno where division= second ; 22.(使用 using 替換連接條件)如:from teams inner join players on te
54、ams.playerno=players.playerno 和下面的語句是相等的:from teams inner join players on using (playerno) 在 penalties 表和 teams 表之間做一個(gè)左外連接。select * from penalties left join teams using (playerno); 23.獲取居住在 stratford 的球員號(hào)碼。select p.playerno from players as p where p.town=stratford; 或者:select playerno from (select *
55、from players where town=stratford) as stratforders; 24.獲取在 first 級(jí)別的球隊(duì)中擔(dān)任隊(duì)長(zhǎng)的每個(gè)球員編號(hào)。select small_teams.playerno from(select playerno,division from teams) as small_teams where small_teams.division=first; mysql 開發(fā)范例- 16 - 25.對(duì)于贏得的局?jǐn)?shù)和輸?shù)舻木謹(jǐn)?shù)之間的差值大于2 的每一場(chǎng)比賽,獲取比賽編號(hào)和比賽之間的差值。select matchno,difference from(sel
56、ect matchno,abs(won-lost) as difference from matches) as m where difference2; 26.創(chuàng)建一個(gè)名為 towns 的虛擬表。select * from (select stratford as town,4 as number union select plymouth,6 union select inglewood,1 union select douglas,2) as towns order by town; 27.對(duì)于每一個(gè)球員,獲得球員編號(hào),姓名,城市以及他居住城市的居民數(shù)目。select playerno,
57、name,players.town,number*1000 from players left outer join (select stratford as town,4 as number union select plymouth,6 union select inglewood,1 union select douglas,2) as towns where players.town=towns.town order by playerno; 28.獲取所居住的城市人口指數(shù)大于2 的球員號(hào)碼。select playerno from players left outer join (s
58、elect stratford as town,4 as number union select plymouth,6 union select inglewood,1 union select douglas,2) as towns on players.town=towns.town where towns.number2; 29.獲取名字為 john,mark 和 arnold 以及姓為 berg、johnson 和 william 的所有可能的組合。select * from(select john as first_name union select mark union selec
59、t arnold) as first_names, (select berg as last_name union select johnson union mysql 開發(fā)范例- 17 - select william) as last_names; 30.對(duì)于數(shù)字 10-19,一次獲取 3 次方的值,如果值大于4000,就不要包含在結(jié)果中。select number,power(number,3) from (select 10 as number union select 11 union select 12 union select 13 union select 14 union s
60、elect 15 union select 16 union select 17 union select 18 union select 19) as numbers where power(number,3)=4000; 31.生成 0-999 之間的數(shù)字,包含999. select number from (select cast(concat(digit1.digit,concat(digit2.digit,digit3.digit) as unsigned integer) as number from (select 0 as digit union select 1 union
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 2025年度毛紗定制化生產(chǎn)購銷合同3篇
- 2025年度模具行業(yè)標(biāo)準(zhǔn)化體系建設(shè)合同范本2篇
- 2024園林工程勞務(wù)分包合同及二零二四年度工程保險(xiǎn)合作協(xié)議2篇
- 雞西2024年黑龍江雞西市部分事業(yè)單位選調(diào)4人筆試歷年典型考點(diǎn)(頻考版試卷)附帶答案詳解版
- 豆類食品加工過程中的智能化解決方案考核試卷
- 新能源汽車動(dòng)力系統(tǒng)-洞察分析
- 硝酸甘油注射劑不良反應(yīng)分析-洞察分析
- 文物數(shù)字化技術(shù)標(biāo)準(zhǔn)化研究-洞察分析
- 閱讀器用戶體驗(yàn)優(yōu)化策略-洞察分析
- 建筑施工過程中的質(zhì)量控制措施
- 計(jì)算機(jī)組成原理習(xí)題答案解析(蔣本珊)
- 板材加工轉(zhuǎn)讓協(xié)議書模板
- GB 44506-2024人民警察警徽
- 咖啡粉代加工協(xié)議書范本
- 2024年北京石景山初三九年級(jí)上學(xué)期期末數(shù)學(xué)試題和答案
- 智慧管網(wǎng)建設(shè)整體解決方案
- 【長(zhǎng)安的荔枝中李善德的人物形象分析7800字(論文)】
- 生物安全風(fēng)險(xiǎn)評(píng)估報(bào)告
- 戈19商務(wù)方案第十九屆玄奘之路戈壁挑戰(zhàn)賽商務(wù)合作方案
- 廣西河池市宜州區(qū)2023-2024學(xué)年七年級(jí)上學(xué)期期末考試數(shù)學(xué)試卷(含解析)
- 2024高考政治真題-哲學(xué)-匯集(解析版)
評(píng)論
0/150
提交評(píng)論