用as可以指定資料庫中表或欄位的別名。在查詢多個表時,如果表名很長可以用別名,以方便使用,也可以使程式碼簡潔一些。如:有兩個表MySite_News_Items, MySite_News_Content 要查詢其中的部份欄位,如果不用別名,應該這樣寫:select MySite_News_Items.Field1, MySite_News_Items.Field2, MySite_News_Items.Field3, MySite_News_Content.Field1 From MySite_News_Items Inner Join MySite_News_Content ON ...用AS就可以這麼寫:select A.Field1, A.Field2, A.Field3, B.Field1 From MySite_News_Items AS A Inner Join MySite_News_Content AS B ON ...如果要查詢兩個表中相同名稱的欄位,也可以用AS來區分。例如:select A.Field1 AS AF1, B.Field1 AS BF1, B.Field2 From MySite_News_Items AS A Inner Join MySite_News_Content AS B ON ...
用as可以指定資料庫中表或欄位的別名。在查詢多個表時,如果表名很長可以用別名,以方便使用,也可以使程式碼簡潔一些。如:有兩個表MySite_News_Items, MySite_News_Content 要查詢其中的部份欄位,如果不用別名,應該這樣寫:select MySite_News_Items.Field1, MySite_News_Items.Field2, MySite_News_Items.Field3, MySite_News_Content.Field1 From MySite_News_Items Inner Join MySite_News_Content ON ...用AS就可以這麼寫:select A.Field1, A.Field2, A.Field3, B.Field1 From MySite_News_Items AS A Inner Join MySite_News_Content AS B ON ...如果要查詢兩個表中相同名稱的欄位,也可以用AS來區分。例如:select A.Field1 AS AF1, B.Field1 AS BF1, B.Field2 From MySite_News_Items AS A Inner Join MySite_News_Content AS B ON ...