TAILIEUCHUNG - The Language of SQL- P7

The Language of SQL- P7: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. | 16 Chapter 2 Basic Data Retrieval Specifying Columns So far we ve done nothing more than simply display all the data in a table. But what if you wanted to select only certain columns Working from the same table you might want to display only the customer s last name for example. The SELECT statement would then look like SELECT LastName FROM Customers and the resulting data would be LastName Smith Lopez Harper If you want to select more than one but not all columns the SELECT might look like SELECT FirstName LastName FROM Customers and the output would appear as FirstName LastName William Smith Natalie Lopez Brenda Harper The general format of this statement is SELECT columnlist FROM table The important thing to remember is that if you need to specify more than one column in the columnlist then those columns must be separated by commas. Column Names with Embedded Spaces 17 Also notice that we placed each column in the columnlist on separate lines. This was done to improve readability. Column Names with Embedded Spaces What if a column contains a space in its name Let s say for example that the LastName column was specified as Last Name instead with a space inserted between the two words . Clearly the following would not work SELECT Last Name FROM Customers This statement would be considered invalid since Last and Name are not column names. And even if Last and Name were proper column names they would need to be separated by a comma. The solution is to use a special character around any column name containing spaces. The character to use differs depending on which database you re using. For Microsoft SQL Server the characters to use are square brackets and the proper syntax is SELECT Last Name FROM Customers One additional syntax note Just as keywords are not case sensitive it s also true that table and column names are not case sensitive. For example the previous example is identical to select last name from customers For clarity s sake I will print all keywords in

TỪ KHÓA LIÊN QUAN
TÀI LIỆU MỚI ĐĂNG
TAILIEUCHUNG - Chia sẻ tài liệu không giới hạn
Địa chỉ : 444 Hoang Hoa Tham, Hanoi, Viet Nam
Website : tailieuchung.com
Email : tailieuchung20@gmail.com
Tailieuchung.com là thư viện tài liệu trực tuyến, nơi chia sẽ trao đổi hàng triệu tài liệu như luận văn đồ án, sách, giáo trình, đề thi.
Chúng tôi không chịu trách nhiệm liên quan đến các vấn đề bản quyền nội dung tài liệu được thành viên tự nguyện đăng tải lên, nếu phát hiện thấy tài liệu xấu hoặc tài liệu có bản quyền xin hãy email cho chúng tôi.
Đã 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.