Upgrade to Pro — share decks privately, control downloads, hide ads and more …

sql-workshop-for-web-director-1

 sql-workshop-for-web-director-1

ディレクタのためのSQL勉強会の時に使用したスライドです。

Yuta Kurotaki

April 01, 2013
Tweet

More Decks by Yuta Kurotaki

Other Decks in Technology

Transcript

  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 σΟϨΫλʔ 13೥4݄1೔݄༵೔
  2. ߲໨ ߲໨ ߲໨ ߲໨ ϩϦϙ͘Μ ͓͡͞Μ ϖύϘ ෱Ԭ Χό͘Μ ಈ෺

    ੨ Ϧε͘Μ υϯάϧ ϧϏʔ γφτϥ ͘·͘Μ ৿ ࡪ ςʔϒϧͰ͸ͳ͍ʂ 13೥4݄1೔݄༵೔
  3. ࣾһ ࣾһJE ࢯ໊ ෦ॺ ৬छ  ϩϦϙ͘Μ MPMJQPQ σβΠφʔ 

    Χό͘Μ IFUFNM ΤϯδχΞ  Ϧε͘Μ TRBMF σβΠφʔ  ͘·͘Μ NVVNVV σΟϨΫλʔ ςʔϒϧʂ 13೥4݄1೔݄༵೔
  4. ࣾһ &NQMPZFFT ࣾһJE ࢯ໊ ෦ॺ ৬छ  ϩϦϙ͘Μ MPMJQPQ σβΠφʔ

     Χό͘Μ IFUFNM ΤϯδχΞ  Ϧε͘Μ TRBMF σβΠφʔ  ͘·͘Μ NVVNVV σΟϨΫλʔ ߦ ʢϨίʔυʣ ྻɺଐੑ ʢΧϥϜʣ 13೥4݄1೔݄༵೔
  5. ࣾһJE ࢯ໊ /BNF ෦ॺ ৬छ  ϩϦϙ͘Μ MPMJQPQ σβΠφʔ 

    Χό͘Μ IFUFNM ΤϯδχΞ  Ϧε͘Μ TRBMF σβΠφʔ  ͘·͘Μ NVVNVV σΟϨΫλʔ &NQMPZFFTςʔϒϧ SELECT Name FROM Employees; ࢯ໊ /BNF ϩϦϙ͘Μ Χό͘Μ Ϧε͘Μ ͘·͘Μ &NQMPZFFTςʔϒϧ͔Βࢯ໊ҰཡΛग़͢৔߹ DataBase 13೥4݄1೔݄༵೔
  6. ࣾһςʔϒϧͷ࡞੒ create table Employees ( EmployeeID int, EmployeeName varchar(24), Email

    varchar(256), Height int(255), Weight int(255), Birthday date, BloodType varchar(2) ); ൒֯εϖʔε ΧϯϚΛ๨Εͣʹ ࠷ޙʹηϛίϩϯ 13೥4݄1೔݄༵೔
  7. ঎඼ςʔϒϧͷ࡞੒ create table Products ( ProductID int, ProductCode int, ProductName

    varchar(50), Price int, CategoryID varchar(100) ); 13೥4݄1೔݄༵೔
  8. &NQMPZFF*% &NQMPZFF /BNF &NBJM )FJHIU 8FJHIU #JSUIEBZ #MPPE5ZQF &NQMPZFFT 1SPEVDU*%

    1SPEVDU$PEF 1SPEVDU/BNF 1SJDF $BUFHPSZ*% 1SPEVDUT 13೥4݄1೔݄༵೔
  9. &NQMPZFFTςʔϒϧʹϨίʔυΛ௥Ճ insert into Employees ( EmployeeID, EmployeeName, Email, Height, Weight,

    Birthday, BloodType ) values ( 1,! 'ϩϦϙ͓͡͞Μ', '[email protected]', 170, 70, '2002-01-01', 'A' ); ൒֯εϖʔε ΧϯϚΛ๨Εͣʹ ࠷ޙʹηϛίϩϯ จࣈྻ ೔෇͸b γϯάϧΫΥʔτ ͰғΉ 13೥4݄1೔݄༵೔
  10. σʔλͷಡΈग़͠ select ProductName from Products ; select EmployeeName, Email from

    Employees ; 1SPEVDUςʔϒϧ͔Β1SPEVDU/BNFΛಡΈग़͢ &NQMPZFFTςʔϒϧ͔Β&NQMPZFF/BNFͱ&NBJMΛಡΈग़͢ 13೥4݄1೔݄༵೔
  11. ԋࢉ select 1 + 1; select Price * 1.05 from

    Products ; select 2 * 2; ͨ͢ ͔͚Δ 1SPEVDUTςʔϒϧͷ1SJDFͷ஋ʹ͔͚Δ 13೥4݄1೔݄༵೔
  12. ؔ਺ w $06/5 w "7( w 46. w ."9 w

    .*/ 13೥4݄1೔݄༵೔
  13. ৚݅Λ͚ͭͯಡΈग़͠ select * from Products where ProductID = 2 ;

    1SPEVDUTςʔϒϧͷ1SPEVDU*%͕ͷϨίʔυΛಡΈग़͢ 13೥4݄1೔݄༵೔
  14. ৚݅Λ͚ͭͯಡΈग़͠ select * from Products where ProductCode >= 1000 and

    Price >= 1000 ; 1SPEVDUTςʔϒϧͷ1SPEVDU$PEF͕Ҏ্͔ͭ1SJDF͕Ҏ্ͷϨίʔυΛಡΈग़͢ 13೥4݄1೔݄༵೔
  15. ύλʔϯϚονͰݕࡧ ޙํҰக select EmployeeName from Employees where EmployeeName like 'ά%'

    ; &NQMPZFFTςʔϒϧͷ&NQMPZFF/BNFͷઌ಄จࣈ͕άͷ&NQMPZFF/BNFΛಡΈग़͢ 13೥4݄1೔݄༵೔
  16. ύλʔϯϚονͰݕࡧ લํҰக select EmployeeName from Employees where EmployeeName like '%࿠'

    ; &NQMPZFFTςʔϒϧͷ&NQMPZFF/BNFͷ࠷ޙͷจࣈ͕࿠ͷ&NQMPZFF/BNFΛಡΈग़͢ 13೥4݄1೔݄༵೔
  17. ߱ॱʹฒͼସ͑ select * from Products where ProductCode >= 800 order

    by ProductID desc ; 1SPEVDUTςʔϒϧͷ1SPEVDU$PEF͕Ҏ্ͷϨίʔυΛ1SPEVDU*%Ͱ߱ॱʹฒͼସ͑ 13೥4݄1೔݄༵೔
  18. ঢॱʹฒͼସ͑ select * from Products where ProductCode >= 800 order

    by ProductID asc ; 1SPEVDUTςʔϒϧͷ1SPEVDU$PEF͕Ҏ্ͷϨίʔυΛ1SPEVDU*%Ͱঢॱʹฒͼସ͑ 13೥4݄1೔݄༵೔