..
In the guide to SQL we have seen how to create partnerships between two tables using INNER JOIN. In this article we will see how to do the same thing as managing no more than two, but three tables.
In reality it is a very simple operation which does not differ from a common JOIN of 2 tables.
Let's make an example: think of a hypothetical purchase of a simple database of e-commerce consists of three tables structured as follows:
users (used for the management of registered users)
SELECT utenti.ute_nome, utenti.ute_cognome, prodotti.prod_nome, prodotti.prod_descrizione, prodotti.prod_prezzo, acquisti.acq_data FROM users INNER JOIN purchases ON = utenti.ute_id acquisti.acq_ute_id INNER JOIN products ON = prodotti.prod_id acquisti.acq_prod_id WHERE utenti.ute_id = 1;As you may have noticed the common FROM clause (which identifies the first table) is followed by two INNER JOIN (which identify the second and the third table) accompanied by the applicable link ON that is "a bridge" in order to create a link rationally between the different tables.
Finally I just have to remind you that, of course, you can use the technique seen above for more complex queries involving 4, 5 or more tables ... in fact I advise you not to exaggerate the construction of such queries, although theoretically feasible, is often labored manageable in practical application.
| |
MS Access (Advanced)
Learn how to create and manage databases quickly and easily. Starting from 29 €. |
| |
MySQL (Course)
Management of open-source database. From 39 €. |
| |
SQL and Database (Course)
Create and manage relational databases. From 39 €. |