Mysql your visual blueprint for creating open source databases- P8
Số trang: 20
Loại file: pdf
Dung lượng: 612.00 KB
Lượt xem: 10
Lượt tải: 0
Xem trước 2 trang đầu tiên của tài liệu này:
Thông tin tài liệu:
Mysql your visual blueprint for creating open source databases- P8:The show tables command displays a list of tables available in the currently selected database. You can use this command when you are unsure of the exact name of a table within the database.
Nội dung trích xuất từ tài liệu:
Mysql your visual blueprint for creating open source databases- P8 USING SELECT QUERIES 6 When you use GROUP BY, you can select any number of This example uses a simple new table, columns as well as functions such as COUNT and AVG that scores. The CREATE TABLE command aggregate the data from the grouped rows. When you are for this table only needs to specify two not using GROUP BY, and you use a function like COUNT or columns. AVG, you cannot select any normal column values in the same query. The following table describes the available Example: functions in MySQL for use with GROUP BY clauses. CREATE TABLE scores ( name VARCHAR(50), FUNCTION DESCRIPTION score INT UNSIGNED); COUNT Number of rows Although this is a very basic table, you can achieve impressive results by storing AVG Average value multiple scores for each name and using SUM Total value the various MySQL grouping functions. MIN Minimum value MAX Maximum value STD Standard deviation BIT_OR Bitwise OR BIT_AND Bitwise AND° Type SELECT name, · Type GROUP BY name; ‚ Type SELECT name, ± Type FROM scores GROUPCOUNT(*) FROM scores and press Enter. AVG(score), and press Enter. BY name; and press Enter.and press Enter. s The number of scores for — Type MIN(score), s The name, average, each student is displayed. MAX(score) and press Enter. minimum score, and maximum score are displayed for each student. 127 MySQLDISPLAY DATA FROM MULTIPLE TABLES relationship between the two tables. In the example above,M ySQL is known as a relational database system, and one of the most important features of a the WHERE condition indicates that rows should be matched relational database is the ability to work with when the author columns from both tables are equal.relationships between different tables. You can use SELECT To refer to columns when working with multiple tables, youto retrieve related data from multiple tables. must specify the table name for each column. Separate theFor example, the quotes table stores quotations and their table and column names with a period. The column youcorresponding authors. If you had a separate table, named match between the tables does not have to be included inauthors, that stored birth and death dates for a list of authors, the results. The following SELECT query displays only theyou could combine the two in a single SELECT query: quote field from the quotes table and the corresponding born field from the authors table:SELECT * FROM quotes, authors WHERE quotes.author = authors.author; SELECT quotes.quote, authors.born FROM quotes, authorsThis query combines, or joins, data from the two tables. WHERE quotes.author = authors.author;Each row in the result includes a combination of thecolumns from the quotes table and the columns of the Although the columns that match across the two tablesauthors table. A row is returned for each row that matches in this example are both named author, the names do notbetween the tables. need to be similar. However, they should ...
Nội dung trích xuất từ tài liệu:
Mysql your visual blueprint for creating open source databases- P8 USING SELECT QUERIES 6 When you use GROUP BY, you can select any number of This example uses a simple new table, columns as well as functions such as COUNT and AVG that scores. The CREATE TABLE command aggregate the data from the grouped rows. When you are for this table only needs to specify two not using GROUP BY, and you use a function like COUNT or columns. AVG, you cannot select any normal column values in the same query. The following table describes the available Example: functions in MySQL for use with GROUP BY clauses. CREATE TABLE scores ( name VARCHAR(50), FUNCTION DESCRIPTION score INT UNSIGNED); COUNT Number of rows Although this is a very basic table, you can achieve impressive results by storing AVG Average value multiple scores for each name and using SUM Total value the various MySQL grouping functions. MIN Minimum value MAX Maximum value STD Standard deviation BIT_OR Bitwise OR BIT_AND Bitwise AND° Type SELECT name, · Type GROUP BY name; ‚ Type SELECT name, ± Type FROM scores GROUPCOUNT(*) FROM scores and press Enter. AVG(score), and press Enter. BY name; and press Enter.and press Enter. s The number of scores for — Type MIN(score), s The name, average, each student is displayed. MAX(score) and press Enter. minimum score, and maximum score are displayed for each student. 127 MySQLDISPLAY DATA FROM MULTIPLE TABLES relationship between the two tables. In the example above,M ySQL is known as a relational database system, and one of the most important features of a the WHERE condition indicates that rows should be matched relational database is the ability to work with when the author columns from both tables are equal.relationships between different tables. You can use SELECT To refer to columns when working with multiple tables, youto retrieve related data from multiple tables. must specify the table name for each column. Separate theFor example, the quotes table stores quotations and their table and column names with a period. The column youcorresponding authors. If you had a separate table, named match between the tables does not have to be included inauthors, that stored birth and death dates for a list of authors, the results. The following SELECT query displays only theyou could combine the two in a single SELECT query: quote field from the quotes table and the corresponding born field from the authors table:SELECT * FROM quotes, authors WHERE quotes.author = authors.author; SELECT quotes.quote, authors.born FROM quotes, authorsThis query combines, or joins, data from the two tables. WHERE quotes.author = authors.author;Each row in the result includes a combination of thecolumns from the quotes table and the columns of the Although the columns that match across the two tablesauthors table. A row is returned for each row that matches in this example are both named author, the names do notbetween the tables. need to be similar. However, they should ...
Tìm kiếm theo từ khóa liên quan:
giáo trình cơ sở dữ liệu quản trị cơ sở dữ liệu MySQL cơ bản bảo mật cơ sở dữ liệu giáo trình sql cơ bảnTài liệu liên quan:
-
62 trang 404 3 0
-
Giáo trình Cơ sở dữ liệu: Phần 2 - TS. Nguyễn Hoàng Sơn
158 trang 299 0 0 -
Đề cương chi tiết học phần Quản trị cơ sở dữ liệu (Database Management Systems - DBMS)
14 trang 251 0 0 -
Giáo trình Cơ sở dữ liệu: Phần 2 - Đại học Kinh tế TP. HCM
115 trang 179 0 0 -
Giáo trình Cơ sở dữ liệu: Phần 1 - Sở Bưu chính Viễn Thông TP Hà Nội
48 trang 176 1 0 -
Giáo Trình về Cơ Sở Dữ Liệu - Phan Tấn Quốc
114 trang 121 1 0 -
Giáo trình cơ sở dữ liệu quan hệ_3
26 trang 106 0 0 -
Giáo trình Cơ sở dữ liệu (Ngành: Công nghệ thông tin - Trung cấp) - Trường Cao đẳng Xây dựng số 1
49 trang 102 0 0 -
Giáo trình: Hệ quản trị cơ sở dữ liệu - Nguyễn Trần Quốc Vinh
217 trang 79 0 0 -
Tiểu Luận Chương Trình Quản Lí Học Phí Trường THPT
18 trang 78 0 0