'i want to join every row of a table with another one in a specific order
I have 2 tables :
years:
id name
1 2022
2 2023
3 2024
4 2025
5 2026
and months :
id name
1 jan
2 feb
3 mar
4 apr 5 jun 6 jul ...
i want to join every row from years to a row from months. something like this :(with this order)
2022 jan
2022 feb
2022 mar
2022 apr
...
2023 jan
2023 feb
....
Please help
Solution 1:[1]
That's cross join (Cartesian product).
select y.name as year,
m.name as month
from years y cross join months m
order by y.name, m.id
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 |
