The row for 500127 (order_id) from the orders table would be omitted, since the supplier_id 10004 does not exist in the suppliers table. The rows for Microsoft and NVIDIA from the supplier table would be omitted, since the supplier_id's 1003 do not exist in both tables. Our result set would look like this: supplier_id If we run the PostgreSQL SELECT statement (that contains an INNER JOIN) below: SELECT suppliers.supplier_id, suppliers.supplier_name, orders.order_date We have another table called orders with three fields (order_id, supplier_id, and order_date). It contains the following data: supplier_id We have a table called suppliers with two fields (supplier_id and supplier_name). Let's look at some data to explain how the INNER JOINS work: This PostgreSQL INNER JOIN example would return all rows from the suppliers and orders tables where there is a matching supplier_id value in both the suppliers and orders tables. ON suppliers.supplier_id = orders.supplier_id Here is an example of a PostgreSQL INNER JOIN: SELECT suppliers.supplier_id, suppliers.supplier_name, orders.order_date The PostgreSQL INNER JOIN would return the records where table1 and table2 intersect. In this visual diagram, the PostgreSQL INNER JOIN returns the shaded area: The syntax for the INNER JOIN in PostgreSQL is: SELECT columns PostgreSQL INNER JOINS return all rows from multiple tables where the join condition is met. Chances are, you've already written a statement that uses a PostgreSQL INNER JOIN.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |