hintcnuie 发表于 2013-1-25 22:24: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 http://www.agoit.com/upload/picture/pic/34801/401ee50f-9c92-34af-b98a-a2c21bd77a13.png
 
 http://www.agoit.com/upload/picture/pic/34803/531bbdce-7c89-3311-9bb5-2c28b887d23a.pnghttp://www.agoit.com/upload/picture/pic/34805/239988df-a4fb-36a2-9e2c-546570795d34.png
页: [1]
查看完整版本: DB2 常用SQL Quick Find