SQL
From SkyWiki
(Difference between revisions)
Line 5: | Line 5: | ||
left outer join | left outer join | ||
+ | |||
+ | <source lang=sql> | ||
+ | </source> | ||
+ | |||
right outer join | right outer join | ||
+ | |||
+ | <source lang=sql> | ||
+ | </source> | ||
+ | |||
inner join | inner join | ||
+ | <source lang=sql> | ||
+ | </source> | ||
+ | |||
+ | |||
+ | ===TOP SELECT=== | ||
+ | MySQL: | ||
+ | <source lang=sql> | ||
+ | SELECT product, descr, email | ||
+ | FROM products | ||
+ | LIMIT 10 | ||
+ | </source> | ||
+ | |||
+ | Oracle >= 8.1.6: | ||
+ | <source lang=sql> | ||
+ | select * from (select | ||
+ | JOB_NUM, | ||
+ | JOB_NME, | ||
+ | START_DT_GMT, | ||
+ | STATUS_CD, | ||
+ | rank() over(partition by JOB_NUM order by START_DT_GMT desc | ||
+ | ) rn | ||
+ | from NM_SCHD_JOB_RUN | ||
+ | ) | ||
+ | where rn < 10 | ||
+ | </source> | ||
- | TOP | + | MS SQL Server: |
+ | MySQL: | ||
+ | <source lang=sql> | ||
+ | SELECT TOP 10 product, descr, email | ||
+ | FROM products | ||
+ | </source> |
Revision as of 06:39, 16 September 2008
traditional Oracle outer join syntax
left outer join
right outer join
inner join
TOP SELECT
MySQL:
SELECT product, descr, email FROM products LIMIT 10
Oracle >= 8.1.6:
SELECT * FROM (SELECT JOB_NUM, JOB_NME, START_DT_GMT, STATUS_CD, rank() over(partition BY JOB_NUM ORDER BY START_DT_GMT DESC ) rn FROM NM_SCHD_JOB_RUN ) WHERE rn < 10
MS SQL Server: MySQL:
SELECT TOP 10 product, descr, email FROM products