cjcmay 发表于 2016-11-15 06:53:02

DB2 常用SQL Quick Find

  Join Rows
  To combine matching rows in multiple tables, use a join

SELECT nm.id ANSWER ,jb.job ID NAME JOB FROM emp_nm nm,emp_jb jb 10 Sanders Sales WHERE nm.id = jb.id 20 Pernal Clerk ORDER BY 1;
  Outer Join
  To get all of the rows from one table, plus the matching rows from another table (if there are
any), use an outer join

SELECT nm.id ANSWER,nm.name ,jb.job ID NAME JOB FROM emp_nm nmLEFT OUTER JOIN 10 Sanders Salesemp_jb jbON nm.id = jb.idORDER BY nm.id;
  Fetch First "n" Rows

To fetch the first "n" matching rows, use the FETCH FIRST notation

SELECT * FROM EMP_MM ORDER BY ID DESC FETCH FIRST 2 ROWS ONLY
 



页: [1]
查看完整版本: DB2 常用SQL Quick Find