How to do everything with PHP (phần 5)

Tham khảo tài liệu 'how to do everything with php (phần 5)', công nghệ thông tin, kỹ thuật lập trình phục vụ nhu cầu học tập, nghiên cứu và làm việc hiệu quả | 184 How to Do Everything with PHP MySQL between the values entered into a field and the field s data type or with missing values and so can automatically perform the following operations For auto_increment fields entering a null value automatically increments the previously generated field value by 1. For the first timestamp field in a table entering a null value automatically inserts the current date and time. For unique or primary key fields entering a value that already exists causes MySQL to generate an error. When inserting string and some date values into a table enclose them in quotation marks so that MySQL doesn t confuse them with variable or field names. Quotation marks within the values themselves can be escaped by preceding them with the backslash symbol. Now that you know how to insert records try inserting some sample records for the three tables created in the previous section using the sample data in Chapter 8 as a reference. You can start with these samples mysql INSERT INTO movies VALUES 1 Rear Window 1954 Query OK 1 row affected sec mysql INSERT INTO persons VALUES 1 Alfred Hitchcock M 1899-08-13 Query OK 1 row affected sec mysql INSERT INTO roles VALUES 1 1 D 1 3 A Query OK 2 rows affected sec Editing and Deleting Records Just as you insert records into a table you can also delete records with the DELETE command which is illustrated in the following mysql DELETE FROM movies Query OK 0 rows affected sec The previous command would delete all the records from the movies table. You can select a specific subset of rows to be deleted by adding the where clause to the delete statement. The following example would only delete records for those persons born after 1960 mysql DELETE FROM movies WHERE myear 1960 Query OK 1 row affected sec TEAM Line CHAPTER 10 Editing Records and Performing Queries 185 CAUTION TIP It is not possible to reverse a DELETE operation in MySQL unless you re in the middle of a InnoDB transaction which hasn

Không thể tạo bản xem trước, hãy bấm tải xuống
Đã 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.