In SQL, what are JOINs?

If you don’t know what a JOIN is, we can explain it this way. Basically, where you’re going to pull information from different tables, you can join them together to get whatever information you want. So you could create all sorts of data by combining different tables anywhere there is a connection. The way that we can do these actions is by using primary keys and foreign keys. Primary keys are unique identifiers per each table, and within each table, there is usually a foreign key that connects it with another table. These primary and foreign keys can be used to make JOINS and combining the rows from two or more tables.

There are four main types of JOINS in SQL. There are FULL JOINs, RIGHT JOINs, LEFT JOINs, and INNER JOINs. When we are combining two tables with INNER JOIN, it can show data that has matching entries in both of the tables. If they do not have a matching entry, then those data will not be displayed in the results. In the LEFT JOIN, all the data of the left table will be displayed irrespective it has a matching entry or it doesn’t have a matching entry on the other table. The RIGHT JOIN is exactly a vice versa of the LEFT JOIN. So all the records from the right table will be displayed irrespective they have an entry in the left table or not. FULL JOUNs are like a combination of INNER JOIN, LEFT JOIN, and RIGHT JOIN. So it will show all non-matching records from the left table as well as non-matching records from the right table.

Leave a Reply

Your email address will not be published. Required fields are marked *