1、Join
MySQL 中的Join, 若其後的 Join 條件有on, 則為Inner Join . 若為where 條件,則為Inner Join
Cross Join with Where == Inner Join with on
SELECT * FROM CITIES CROSS JOIN FLIGHTS
WHERE CITIES.AIRPORT = FLIGHTS.ORIG_AIRPORT
SELECT * FROM CITIES INNER JOIN FLIGHTS
ON CITIES.AIRPORT = FLIGHTS.ORIG_AIRPORT
2、Alias
在oracle中,alias 用在column 中,是可以用as xxx 來替代
但如果對Table alias ,則只有一種方式,
表示法為 : from Table_name AAA ==> AAA為alias name
as 在table 這個地方有個用途,是用來做為版本查詢
Oracle 在經過設定後,可以保留一定時間的舊資料
若您在查詢某一系統時間時,table的欄位值就可以透過 Table as of timestamp來查詢
範例如下:
SELECT salary FROM employees
WHERE last_name = 'Chung';
SALARY
----------
3800
UPDATE employees SET salary = 4000
WHERE last_name = 'Chung';
1 row updated.
SELECT salary FROM employees
WHERE last_name = 'Chung';
SALARY
----------
4000
To learn what the value was before the update, you can use the following Flashback Query:
SELECT salary FROM employees
AS OF TIMESTAMP (SYSTIMESTAMP - INTERVAL '1' MINUTE) ==>查詢系統一分鐘前的資料
WHERE last_name = 'Chung';
SALARY
----------
3800
因此結論是,若在from 後面的alias 一 律把as 拿掉,才能順利在Oracle 中執行
沒有留言:
張貼留言