Performing Joins

Because relational databases are more complexly structured, they sometimes require special query statements to retrieve the information you need most. For example, if you wanted to know what categories the www.php.net URL is filed under, you would need to find its url_id from the urls table, use that to retrieve all the url_category_ids from the url_associations table, and then retrieve the actual category values from the url_categories table for those url_category_ids. As you can see, this requires several steps and queries. By using a join—an SQL query performed by cross-referencing tables—you can accomplish all of that in one fell swoop.

Several types of joins are conceivable according to SQL. Beginning to intermediate users ...

Get PHP and MySQL for Dynamic Web Sites: Visual Quickpro Guide, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.