Changes

Joining Tables in MySQL

31 bytes added, 14:19, 19 March 2009
How Does a Join Work?
== How Does a Join Work? ==
<google>ADSDAQBOX_FLOW</google>
A join works through the use of keys. Continuing our example, our ''supplier'' table contains a column designated as the ''supplier_id''. This column is configured as the primary key (for details on primary keys see [[Database Basics]]). The ''product'' table contains all of the products sold by our company, including product id, product description and product name. In addition it also contains the supplier id of the supplier from which we buy the individual products. Because this is a key from a different table,(the ''suppliers'' table) it is referred to a as ''foreign key''. When using a ''SELECT'' statement to retrieve data from the product table we can use this foreign key to extract the relevant supplier information from the supplier table for each product.