The Language of SQL- P9

The Language of SQL- P9:Research has shown that, being pressed for time, most readers tend to skip the introduction of any book they happen to read and then proceed immediately to the first real chapter. With that fact firmly in mind, we will only cover relatively unimportant material in the introduction, such as an explanation of what you will and will not learn by reading this book. | 26 Chapters Calculations and Aliases Table Aliases In addition to providing alternate names for columns aliases can also be specified for tables using the same AS keyword. There are three general reasons for using table aliases. The first reason relates to tables with obscure or complex names. For example if a table is named Orders123 you can use the following SELECT to give it an alias of Orders. SELECT LastName FROM Orders123 AS Orders Unlike column aliases table aliases are not enclosed in quotes. When using table aliases you have the option of using the alias as a prefix for any selected columns. For example the above could also be written as SELECT FROM Orders123 AS Orders The prefix Orders has now been added as a prefix to LastName using a period to separate the prefix from the column name. In this situation the prefix wasn t necessary. However when data is selected from multiple tables the prefix will sometimes be required. This will be seen in later chapters. DATABASE DIFFERENCES Oracle In Oracle table aliases are specified without the as keyword. The syntax for the previous statement in Oracle is SELECT FROM Orders123 Orders Two remaining reasons for using table aliases will be covered in Chapters 11 and 14 Situations when selecting from multiple tables Situations when using a subquery in a SELECT statement Looking Ahead 27 The meaning of the term subquery will become clear in Chapter 14 when the topic is covered in detail. Looking Ahead In this chapter you learned about three general ways to create calculated fields in a SELECT statement. First literal values can be used to select specific words or values. Second arithmetic calculations can be used to perform calculations on single or multiple columns. Third concatenation can be used to combine columns and literal values together. We also discussed the related topic of column aliases which are often employed when using calculated fields. In the next chapter we ll be moving

Không thể tạo bản xem trước, hãy bấm tải xuống
TỪ KHÓA LIÊN QUAN
TÀI LIỆU MỚI ĐĂNG
16    88    2    02-07-2024
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.