Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
sql-workshop-for-web-director-1
Search
Yuta Kurotaki
April 01, 2013
Technology
0
150
sql-workshop-for-web-director-1
ディレクタのためのSQL勉強会の時に使用したスライドです。
Yuta Kurotaki
April 01, 2013
Tweet
Share
More Decks by Yuta Kurotaki
See All by Yuta Kurotaki
CTO Night & Day 2024 Product Feedback Lunch
kurotaky
1
140
ゼロからわかるリザバーコンピューティング
kurotaky
1
1.5k
SUZURI DX 2023
kurotaky
1
180
How GitHub Copilot Transforms Development Productivity
kurotaky
18
13k
The story of repairing my junk keyboard with The kinT keyboard controller
kurotaky
0
1.6k
DevRel_Japan CONFERENCE 2023
kurotaky
1
1.9k
ctoa-wakate-01-company-introduction
kurotaky
0
290
Ethereum for Ruby
kurotaky
2
2k
NFTコンテンツでオリジナルグッズ作成を支える技術
kurotaky
1
180
Other Decks in Technology
See All in Technology
夢の印税生活 / Life on Royalties
tmtms
0
290
コスト削減の基本の「キ」~ コスト消費3大リソースへの対策 ~
smt7174
2
180
Amazon Bedrock AgentCore でプロモーション用動画生成エージェントを開発する
nasuvitz
6
440
DeNA での思い出 / Memories at DeNA
orgachem
PRO
3
1.6k
自社製CMSからmicroCMSへのリプレースがプロダクトグロースを加速させた話
nextbeatdev
0
140
攻撃と防御で実践するプロダクトセキュリティ演習~導入パート~
recruitengineers
PRO
2
310
【 LLMエンジニアがヒューマノイド開発に挑んでみた 】 - 第104回 Machine Learning 15minutes! Hybrid
soneo1127
0
110
知られざるprops命名の慣習 アクション編
uhyo
11
2.6k
実践アプリケーション設計 ③ドメイン駆動設計
recruitengineers
PRO
3
320
mruby(PicoRuby)で ファミコン音楽を奏でる
kishima
1
280
JOAI発表資料 @ 関東kaggler会
joai_committee
1
370
我々は雰囲気で仕事をしている / How can we do vibe coding as well
naospon
2
220
Featured
See All Featured
It's Worth the Effort
3n
187
28k
A better future with KSS
kneath
239
17k
The Cost Of JavaScript in 2023
addyosmani
53
8.8k
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
PRO
23
1.4k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
53
2.9k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
333
22k
[RailsConf 2023] Rails as a piece of cake
palkan
56
5.8k
BBQ
matthewcrist
89
9.8k
Six Lessons from altMBA
skipperchong
28
4k
Learning to Love Humans: Emotional Interface Design
aarron
273
40k
The Language of Interfaces
destraynor
160
25k
Principles of Awesome APIs and How to Build Them.
keavy
126
17k
Transcript
8FCσΟϨΫλʔͷͨΊͷ 42-ษڧձ 134݄1݄༵
42- wϦϨʔγϣφϧσʔλϕʔεͷૢ࡞Λ ߦ͏ͨΊͷݴޠ 134݄1݄༵
SELECT CustomerName FROM Customers; 134݄1݄༵
ϦϨʔγϣφϧσʔλϕʔεʁ w3%#3FMBUJPOBM%BUBCBTF w࠷͘ར༻͞Ε͍ͯΔσʔλϕʔε wσʔλΛਓ͕ؒཧղ͍͢͠ೋ࣍ݩද ͷܗࣜͰཧ 134݄1݄༵
ϦϨʔγϣφϧσʔλϕʔε JE ࢯ໊ ෦ॺ ৬छ ϩϦϙ͘Μ MPMJQPQ σβΠφʔ
Χό͘Μ IFUFNM ΤϯδχΞ Ϧε͘Μ TRBMF σβΠφʔ ͘·͘Μ NVVNVV σΟϨΫλʔ JE ࢯ໊ ෦ॺ ৬छ ϩϦϙ͘Μ MPMJQPQ σβΠφʔ Χό͘Μ IFUFNM ΤϯδχΞ Ϧε͘Μ TRBMF σβΠφʔ ͘·͘Μ NVVNVV σΟϨΫλʔ JE ࢯ໊ ෦ॺ ৬छ ϩϦϙ͘Μ MPMJQPQ σβΠφʔ Χό͘Μ IFUFNM ΤϯδχΞ Ϧε͘Μ TRBMF σβΠφʔ ͘·͘Μ NVVNVV σΟϨΫλʔ JE ࢯ໊ ෦ॺ ৬छ ϩϦϙ͘Μ MPMJQPQ σβΠφʔ Χό͘Μ IFUFNM ΤϯδχΞ Ϧε͘Μ TRBMF σβΠφʔ ͘·͘Μ NVVNVV σΟϨΫλʔ ࣾһJE ࢯ໊ ෦ॺ ৬छ ϩϦϙ͘Μ MPMJQPQ σβΠφʔ Χό͘Μ IFUFNM ΤϯδχΞ Ϧε͘Μ TRBMF σβΠφʔ ͘·͘Μ NVVNVV σΟϨΫλʔ 134݄1݄༵
ςʔϒϧʁ w ςʔϒϧͱදݫີʹಉ͡ͷͰͳ͍ 134݄1݄༵
߲ ߲ ߲ ߲ ϩϦϙ͘Μ ͓͡͞Μ ϖύϘ Ԭ Χό͘Μ ಈ
੨ Ϧε͘Μ υϯάϧ ϧϏʔ γφτϥ ͘·͘Μ ࡪ ςʔϒϧͰͳ͍ʂ 134݄1݄༵
ࣾһ ࣾһJE ࢯ໊ ෦ॺ ৬छ ϩϦϙ͘Μ MPMJQPQ σβΠφʔ
Χό͘Μ IFUFNM ΤϯδχΞ Ϧε͘Μ TRBMF σβΠφʔ ͘·͘Μ NVVNVV σΟϨΫλʔ ςʔϒϧʂ 134݄1݄༵
ςʔϒϧ w ܗ͚ͩʮೋ࣍ݩදʯͰ͋Δ͚ͩͰμϝ w ڞ௨Λ࣋ͬͨϨίʔυΛूΊͨͷ w ςʔϒϧ໊ෳܗͰॻ͚Δ 134݄1݄༵
ࣾһ &NQMPZFFT ࣾһJE ࢯ໊ ෦ॺ ৬छ ϩϦϙ͘Μ MPMJQPQ σβΠφʔ
Χό͘Μ IFUFNM ΤϯδχΞ Ϧε͘Μ TRBMF σβΠφʔ ͘·͘Μ NVVNVV σΟϨΫλʔ ߦ ʢϨίʔυʣ ྻɺଐੑ ʢΧϥϜʣ 134݄1݄༵
ࣾһJE ࢯ໊ /BNF ෦ॺ ৬छ ϩϦϙ͘Μ MPMJQPQ σβΠφʔ
Χό͘Μ IFUFNM ΤϯδχΞ Ϧε͘Μ TRBMF σβΠφʔ ͘·͘Μ NVVNVV σΟϨΫλʔ &NQMPZFFTςʔϒϧ SELECT Name FROM Employees; ࢯ໊ /BNF ϩϦϙ͘Μ Χό͘Μ Ϧε͘Μ ͘·͘Μ &NQMPZFFTςʔϒϧ͔Βࢯ໊ҰཡΛग़͢߹ DataBase 134݄1݄༵
QIQ.Z"ENJOΛͬͯσʔλϕʔε Λૢ࡞ͯ͠ΈΑ͏ w.Z42-αʔόʔΛϒϥβ ͔Βૢ࡞Ͱ ͖·͢ wࠓճIFUFNM ϔςϜϧ Λ͍·͢ 134݄1݄༵
IUUQIFUFNMKQ ʮਃ͠ࠐΈʯ͔ΒΞΧϯτΛ࡞ͯ͠Լ͍͞ʂ 134݄1݄༵
ΞΧϯτ࡞ޙίϯτϩʔϧύωϧʹϩάΠϯɺ ʮσʔλϕʔεʯΛબ 134݄1݄༵
ʮσʔλϕʔε࡞ը໘ʯϘλϯΛΫϦοΫ 134݄1݄༵
σʔλϕʔε໊ͱύεϫʔυΛೖྗͯ͠ ʮσʔλϕʔεΛ࡞͢ΔʯΛΫϦοΫ 134݄1݄༵
σʔλϕʔεͷ࡞͕ྃͨ͠ΒʮΔʯΛΫϦοΫ 134݄1݄༵
ʮQIQ.Z"ENJOʯϘλϯΛΫϦοΫ͢Δ 134݄1݄༵
ઃఆͨ͠Ϣʔβ໊ͱύεϫʔυΛೖྗͯ͠ ʮ࣮ߦ͢ΔʯϘλϯΛΫϦοΫ 134݄1݄༵
ςʔϒϧͷ࡞ create table ςʔϒϧ໊ ( ΧϥϜ໊ ܕ, ΧϥϜ໊ ܕ );
֯εϖʔε 134݄1݄༵
σʔλͷܕ wJOU wDIBS WBSDIBSɹจࣈྻ wEBUF 134݄1݄༵
ࣾһςʔϒϧͷ࡞ create table Employees ( EmployeeID int, EmployeeName varchar(24), Email
varchar(256), Height int(255), Weight int(255), Birthday date, BloodType varchar(2) ); ֯εϖʔε ΧϯϚΛΕͣʹ ࠷ޙʹηϛίϩϯ 134݄1݄༵
ςʔϒϧͷ࡞ create table Products ( ProductID int, ProductCode int, ProductName
varchar(50), Price int, CategoryID varchar(100) ); 134݄1݄༵
&NQMPZFF*% &NQMPZFF /BNF &NBJM )FJHIU 8FJHIU #JSUIEBZ #MPPE5ZQF &NQMPZFFT 1SPEVDU*%
1SPEVDU$PEF 1SPEVDU/BNF 1SJDF $BUFHPSZ*% 1SPEVDUT 134݄1݄༵
ςʔϒϧͷ֬ೝ show tables; ςʔϒϧҰཡදࣔ ςʔϒϧͷ֬ೝ desc Employees; ֯εϖʔε 134݄1݄༵
σʔλϕʔεͷૢ࡞ w࡞ $SFBUF wಡΈग़͠ 3FBE wߋ৽ 6QEBUF wআ %FMFUF 134݄1݄༵
ϨίʔυͷՃ insert into ςʔϒϧ໊ ( ΧϥϜ໊, ΧϥϜ໊ ) values (
, ; ֯εϖʔε 134݄1݄༵
&NQMPZFFTςʔϒϧʹϨίʔυΛՃ insert into Employees ( EmployeeID, EmployeeName, Email, Height, Weight,
Birthday, BloodType ) values ( 1,! 'ϩϦϙ͓͡͞Μ', '
[email protected]
', 170, 70, '2002-01-01', 'A' ); ֯εϖʔε ΧϯϚΛΕͣʹ ࠷ޙʹηϛίϩϯ จࣈྻ b γϯάϧΫΥʔτ ͰғΉ 134݄1݄༵
1SPEVDUTςʔϒϧʹϨίʔυΛՃ insert into Products ( ProductID, ProductCode, ProductName, Price, CategoryID
) values ( 1,! 1001, 'lolipop', 105, 1 ); 134݄1݄༵
σʔλͷಡΈग़͠ select ྻ໊, ྻ໊ from ςʔϒϧ໊ ; 134݄1݄༵
σʔλͷಡΈग़͠ select ProductName from Products ; select EmployeeName, Email from
Employees ; 1SPEVDUςʔϒϧ͔Β1SPEVDU/BNFΛಡΈग़͢ &NQMPZFFTςʔϒϧ͔Β&NQMPZFF/BNFͱ&NBJMΛಡΈग़͢ 134݄1݄༵
શΧϥϜಡΈग़͢ select * from Employees ; &NQMPZFFTςʔϒϧ͔ΒશΧϥϜಡΈग़͢ 134݄1݄༵
ԋࢉ ͠ࢉ Ҿ͖ࢉ ֻ͚ࢉ ׂΓࢉ ༨ࢉ 134݄1݄༵
ԋࢉ select 1 + 1; select Price * 1.05 from
Products ; select 2 * 2; ͨ͢ ͔͚Δ 1SPEVDUTςʔϒϧͷ1SJDFͷʹ͔͚Δ 134݄1݄༵
ؔ w $06/5 w "7( w 46. w ."9 w
.*/ 134݄1݄༵
Ձ֨ͷ࠷େɺฏۉΛٻΊΔ select AVG(Price) from Products; select MAX(Price) from Products; 1SPEVDUTςʔϒϧͷ1SJDFͷͷฏۉΛٻΊΔ
1SPEVDUTςʔϒϧͷ1SJDFͷͷ࠷େΛٻΊΔ 134݄1݄༵
݅Λ͚ͭͯಡΈग़͠ select * from Products where ProductID = 2 ;
1SPEVDUTςʔϒϧͷ1SPEVDU*%͕ͷϨίʔυΛಡΈग़͢ 134݄1݄༵
݅Λ͚ͭͯಡΈग़͠ select * from Products where ProductCode >= 1000 and
Price >= 1000 ; 1SPEVDUTςʔϒϧͷ1SPEVDU$PEF͕Ҏ্͔ͭ1SJDF͕Ҏ্ͷϨίʔυΛಡΈग़͢ 134݄1݄༵
ύλʔϯϚονͰݕࡧ ޙํҰக select EmployeeName from Employees where EmployeeName like 'ά%'
; &NQMPZFFTςʔϒϧͷ&NQMPZFF/BNFͷઌ಄จࣈ͕άͷ&NQMPZFF/BNFΛಡΈग़͢ 134݄1݄༵
ύλʔϯϚονͰݕࡧ લํҰக select EmployeeName from Employees where EmployeeName like '%'
; &NQMPZFFTςʔϒϧͷ&NQMPZFF/BNFͷ࠷ޙͷจࣈ͕ͷ&NQMPZFF/BNFΛಡΈग़͢ 134݄1݄༵
߱ॱʹฒͼସ͑ select * from Products where ProductCode >= 800 order
by ProductID desc ; 1SPEVDUTςʔϒϧͷ1SPEVDU$PEF͕Ҏ্ͷϨίʔυΛ1SPEVDU*%Ͱ߱ॱʹฒͼସ͑ 134݄1݄༵
ঢॱʹฒͼସ͑ select * from Products where ProductCode >= 800 order
by ProductID asc ; 1SPEVDUTςʔϒϧͷ1SPEVDU$PEF͕Ҏ্ͷϨίʔυΛ1SPEVDU*%Ͱঢॱʹฒͼସ͑ 134݄1݄༵
ୈೋճΔͷͰΑΖ͓͘͠ئ͍͠·͢ 134݄1݄༵
͓͢͢Ίຊ wվగ৽൛෮ֶशιϑτ͖42-ॻ͖ ํυϦϧ 134݄1݄༵