1. Trang chủ
  2. » Giáo Dục - Đào Tạo

Session 11

15 37 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 15
Dung lượng 810,59 KB

Nội dung

MySQL SELECT DISTINCT • This qualifier (and its synonym DISTINCTROW) allows you to weed out multiple entries when they contain the same data 12/20/2016 Using the LIKE qualifer • The % will also match if there is nothing in the position it occupies; in other words, it can match an empty string 12/20/2016 SELECT COUNT • it displays the number of rows in the table by passing * as a parameter, which means all rows 12/20/2016 LIMIT • The LIMIT qualifier enables you to choose how many rows to return in a query, and where in the table to start returning them When passed a single parameter, it tells MySQL to start at the beginning of the results and just return the number of rows given in that parameter 12/20/2016 ORDER BY • ORDER BY sorts returned results by one or more columns in ascending or descending order • If you wanted to sort all the rows by author and then by descending year of publica‐ tion (to view the most recent first), you would issue the following query: 12/20/2016 GROUP BY • In a similar fashion to ORDER BY, you can group results returned from queries using GROUP BY, which is good for retrieving information about a group of data For example, if you want to know how many publications there are of each category in the classics table, you can issue the following query: 12/20/2016 Relationships • A one-to-one relationship is like a (traditional) marriage: each item has a relationship to only one item of the other type This is surprisingly rare For instance, an author can write multiple books, a book can have multiple authors, and even an address can be associated with multiple customers 12/20/2016 1-1 • Usually, when two items have a one-to-one relationship, you just include them as columns in the same table There are two reasons for splitting them into separate tables: - You want to be prepared in case the relationship changes later - The table has a lot of columns, and you think that performance or maintenance would be improved by splitting it 12/20/2016 One-to-Many • One-to-many (or many-to-one) relationships occur when one row in one table is linked to many rows in another table 12/20/2016 10 Many-to-Many • In a many-to-many relationship, many rows in one table are linked to many rows in another table To create this relationship, add a third table containing the same key column from each of the other tables This third table contains nothing else, as its sole purpose is to link up the other tables 12/20/2016 11 Many-to-Many 12/20/2016 12 Subquery • Demo in class 12/20/2016 13 Backing Up and Restoring 12/20/2016 14 • THANK YOU 12/20/2016 15 ... third table contains nothing else, as its sole purpose is to link up the other tables 12/20/2016 11 Many-to-Many 12/20/2016 12 Subquery • Demo in class 12/20/2016 13 Backing Up and Restoring 12/20/2016

Ngày đăng: 27/10/2019, 22:47

TÀI LIỆU CÙNG NGƯỜI DÙNG

  • Đang cập nhật ...

TÀI LIỆU LIÊN QUAN

w