Help as I need to join two different tables. Please see the details below.
帮助,因为我需要加入两个不同的表。请参阅下面的详细信息。
Rates
价格
ID RateName
1 Standard
2 Special
3 Custom
Dates
日期
ID Date
1 10/01/2017
2 10/02/2017
3 10/03/2017
Expected Result
预期结果
ID RateName Date
1 Standard 10/01/2017
1 Standard 10/02/2017
1 Standard 10/03/2017
2 Special 10/01/2017
2 Special 10/02/2017
2 Special 10/03/2017
3 Custom 10/01/2017
3 Custom 10/02/2017
3 Custom 10/03/2017
2 个解决方案
#1
3
You are looking for a cross join
:
您正在寻找交叉联接:
select r.*, d.*
from rates r cross join
dates d
order by r.id, d.date;
#2
1
You can simply select from two table without any join condition to get the desired result. That will apply cross join
您只需从两个表中选择,无需任何连接条件即可获得所需的结果。这将适用于交叉连接
select r.ID, r.RateName, d.Date
from rates r ,dates d
order by r.ID, d.date
#1
3
You are looking for a cross join
:
您正在寻找交叉联接:
select r.*, d.*
from rates r cross join
dates d
order by r.id, d.date;
#2
1
You can simply select from two table without any join condition to get the desired result. That will apply cross join
您只需从两个表中选择,无需任何连接条件即可获得所需的结果。这将适用于交叉连接
select r.ID, r.RateName, d.Date
from rates r ,dates d
order by r.ID, d.date