[training]ASP.NET MVC 5 – DML 資料操縱語言2

SELECT * FROM SCORE
  WHERE COURSE = '物件導向程式設計'
  
SELECT * FROM SCORE
  WHERE COURSE LIKE '%程式設計%'
  
SELECT * FROM SCORE
  ORDER BY SCORE DESC
  
================================

--SQL註解1
/*SQL註解2*/

================================

--別名
SELECT S.COURSE FORM SCORE S

===============================

--合併表格 INNER JOIN
SELECT P.NAME, S.SID, S.SCORE, S.COURSE
  FROM SCORE S
  INNER JOIN STUDENT P ON S.SID = P.SID
  
--簡化寫法
SELECT P.NAME, S.SID, S.SCORE, S.COURSE
  FROM SCORE S, STUDENT P
  WHERE S.SID = P.SID
  
==================================

--LEFT OUTTER JOIN
SELECT P.NAME, S.SID, S.COURSE, S.SCORE
  FROM SCORE S, 
  LEFT OUTTER JOIN STUDENT P ON S.SID = P.PID

--RIGHT OUTTER JOIN
SELECT P.NAME, S.SID, S.COURSE, S.SCORE
  FROM SCORE S, 
  RIGHT OUTTER JOIN STUDENT P ON S.SID = P.PID
  
--FULL OUTTER JOIN
SELECT P.NAME, S.SID, S.COURSE, S.SCORE
  FROM SCORE S, 
  FULL OUTTER JOIN STUDENT P ON S.SID = P.PID

Leave a Comment

Please note: Comment moderation is enabled and may delay your comment. There is no need to resubmit your comment.