'Select all rows from joined with multiple conditions tables with null values

I want to join two tables, Sales and Budget.

Sales table columns:

| Customer | Period | Sales |

Budget table columns:

| Customer | Period | SaleBudget |

Sales table has data for periods 1, 2, and 3. Budget has data for periods 1-12. When I try to run below query I get only data for periods from Sales table matched with Budget table. But my goal is to get all data from both tables. Could you give me a hint how to change query?

Select s.Customer, b.SaleBudget, s.Sales from Sales s
full outer join Budget b on b.Customer = s.Customer and b.Period = s.Period


Solution 1:[1]

When you use left join its join the rows that are same in

b.Customer = s.Customer and b.Period = s.Period

if you want have all of the rows you shouldn't use left join; The LEFT JOIN keyword returns all records from the left table (table1), and the matching records from the right table (table2); there is not any way that get some data matching and some data Inconsistency in one shape.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 mhhabibi