Abstract
The previous chapter showed you how to use INNER JOIN and LEFT JOIN to retrieve information stored in multiple tables. You also learned how to link existing tables by adding an extra column to the child table and updating each record individually to insert a foreign key. However, most of the time you'll want to insert data simultaneously in both tables. That presents a challenge, because INSERT commands can operate on only one table at a time. You need to handle the insert operations in the correct sequence, starting with the parent table, so that you can get the new record's primary key and insert it in the child table at the same time as other details. Similar considerations also need to be taken into account when updating and deleting records. The code involved isn't difficult, but you need to keep the sequence of events clearly in mind as you build the scripts.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Author information
Authors and Affiliations
Rights and permissions
Copyright information
© 2014 David Powers
About this chapter
Cite this chapter
Powers, D. (2014). Managing Multiple Database Tables. In: PHP Solutions. Apress, Berkeley, CA. https://doi.org/10.1007/978-1-4842-0635-5_16
Download citation
DOI: https://doi.org/10.1007/978-1-4842-0635-5_16
Published:
Publisher Name: Apress, Berkeley, CA
Print ISBN: 978-1-4842-0636-2
Online ISBN: 978-1-4842-0635-5
eBook Packages: Professional and Applied ComputingProfessional and Applied Computing (R0)Apress Access Books