PHP 5/MySQL Programming- P70

PHP 5/MySQL Programming- P70:computer programming has often been seen as a difficult and arcane skill. Programming languages are difficult and complicated, out of the typical person’s reach. However, the advent of the World Wide Web has changed that to some extent. It’s reasonably easy to build and post a Web page for the entire world to see. The language of the Web is reasonably simple, and numerous applications are available to assist in the preparation of static pages | 323 You might want to get a listing of all heroes in your database whose last name begins with an E or perhaps somebody parked a Yak Dirigible in your parking space and need to know who the driver is. You may also want your list sorted by special power or list only vehicles. All these admittedly contrived examples involve grabbing a subset of the original data. The SELECT statement is the SQL workhorse. 1. Click the SQL tab to get a query screen in phpMyAdmin. 2. Type in a query. 3. Click the Go button to see the query results. You ve seen the simplest form of this command getting all the data in a table like this SELECT FROM hero Figure shows this form of the SELECT statement operating on the hero table. figure The SELECT query is in the top section and the results are shown underneath. phpMyAdmin is a wonderful tool for experimenting with SELECT statements because you can write the actual SQL by hand and see immediate results in a very clean format. If you don t want to or cannot use phpMyAdmin do the same experiments directly in MySQL. It will work but the results are formatted as text and not always as easy to see. Chapter 9 Using MySQL to Create Databases 324 PHP 5 MySQL Programming for the Absolute Beginner The SELECT statement is extremely powerful because it can grab a subset of data that can return only the requested fields and records. This process of asking questions of the database is commonly called a query. Note that phpMyAdmin sometimes adds elements to the query notably the limit information . This increases the query s efficiency but doesn t substantially change the query. Limiting Columns You might not want all of the fields in a table. For example you might just want a list of the name and weapon of everyone on your list. You can specify this by using the following SELECT statement which is illustrated in Figure SELECT name weapon FROM hero figure This query returns only the names and weapons. This may seem like a silly .

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