PHP and MySQL Web Development - P48

PHP and MySQL Web Development - P48: PHP and MySQL Web Development teaches the reader to develop dynamic, secure, commercial Web sites. Using the same accessible, popular teaching style of the first edition, this best-selling book has been updated to reflect the rapidly changing landscape of MySQL and PHP. | Retrieving Data from the Database 207 ------------------ ---------------------- name city Julie Smith Airport West Alan Wong Box Hill Michelle Arthur Yarraville Melissa Jones Nar Nar Goon North Michael Archer Leeton As you can see we ve got a table which contains the items we selected name and city from the table we specified data is shown for all the rows in the Customer table. You can specify as many columns as you like from a table by listing them out after the select can also specify some other items. One useful one is the wildcard operator which matches all the columns in the specified table or tables. For example to retrieve all columns and all rows from the order_items table we would use select from order_items which will give the following output --------- ---------------- -------- orderid isbn quantity --------- ---------------- -------- 1 0-672-31697-8 2 2 0-672-31769-9 1 3 0-672-31769-9 1 3 0-672-31509-2 1 4 0-672-31745-1 3 --------- ---------------- -------- Retrieving Data with Specific Criteria In order to access a subset of the rows in a table we need to specify some selection can do this with a WHERE clause. For example select from orders where customerid 3 will select all the columns from the orders table but only the rows with a customerid of 3. Here s the output The WHERE clause specifies the criteria used to select particular rows. In this case we have selected rows with a customerid of single equal sign is used to test 208 Chapter 9 Working with Your MySQL Database equality note that this is different from PHP and it s easy to become confused when you re using them together. In addition to equality MySQL supports a full set of comparison operators and regular ones you will most commonly use in WHERE clauses are listed in Table . Note that this is not a complete list if you need something not listed here check the MySQL manual. Table Useful Comparison Operators for WHERE .

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.