I need to select all from these two tables. Is it possible?
Asked
Active
Viewed 60 times
1 Answers
-2
With the following query you can select all data from one table:
SELECT * FROM Order;
If you want to select all data from two tables you can use a join in the select query to connect the data of the two tables:
SELECT * FROM Order
JOIN Product ON Order.p_id = Product.p_id;
There are different kinds of joins available. Based on the one you use can change the amount of data you will receive. The different kinds of joins are:
- (Inner) join: Returns records that have matching values in both tables
- Left (Outer) join: Return all records from the left table, and the matched records from the right table
- Right (outer) join: Return all records from the right table, and the matched records from the left table
- Full (outer) join: Return all records when there is a match in either left or right table
The information about the different kinds of joins comes from the following website:https://www.w3schools.com/sql/sql_join.asp

coding project
- 12
- 2