PHP 5/MySQL Programming- P80

PHP 5/MySQL Programming- P80: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 | Using a Join to Connect Tables The only downside to disconnecting the data tables is the necessity to rejoin the data when needed. The user doesn t care that the operation and the agent are in different tables but he will want the data to look as if they were on the same table. The secret to reattaching tables is a tool called the inner join. Take a look at the following SELECT statement in SQL SELECT AS agent AS operation FROM agent operation WHERE ORDER BY At first glance this looks like an ordinary query but it is a little different. It joins data from two different tables. Table illustrates the results of this query. Table Combining Two Tables Agent Operation Blackford Enduring Angst Bond Dancing Elephant Cardinal Enduring Angst Falcon Dancing Elephant Rahab Furious Dandelion Chapter 11 Data Normalization Creating Useful Joins An SQL query can pull data from more than one table. To do this follow a few basic rules. Specify the field names more formally if necessary. Notice that the SELECT statement specifies rather than simply name. This is necessary because both tables contain a field called name. Using the syntax is much like using a person s first and last name. It s not necessary if there s no chance of confusion but in a larger environment the more complete naming scheme can avoid confusion. Use the AS clause to clarify your output. This provides an alias for the column and provides a nicer output. 374 PHP 5 MySQL Programming for the Absolute Beginner Modify the FROM clause so it indicates both of the tables you re pulling data from. The FROM clause up to now has only specified one table. In this example it s necessary to specify that data will be coming from two different tables. Indicate how the tables will be connected using a modification of the WHERE clause. Examining a Join without a WHERE Clause The WHERE clause helps clarify the .

Không thể tạo bản xem trước, hãy bấm tải xuống
TÀI LIỆU MỚI ĐĂ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.