我希望将两个表连接到临时表中,然后在选择查询中使用临时表。这是我要创建的临时表的select语句:
rails generate
为上述方法创建临时表的最简单方法是什么?
答案 0 :(得分:2)
您可以创建一个临时表(您可能想要),但如果您还不知道,我想指出您可以在这样的查询中创建虚拟临时表
SELECT *
FROM (
select program, event
from OMEGA.HP
inner join POM.GT on program = substring(name,7,4)
where LENGTH(name)= 25
) AS Virtual_table
你甚至可以像这样加入其中一个表:
SELECT *
FROM (
select program, event
from OMEGA.HP
inner join POM.GT on program = substring(name,7,4)
where LENGTH(name)= 25
) AS v_table74
join (
select program, event
from OMEGA.HP
inner join POM.GT on program = substring(name,2,5)
where LENGTH(name)= 25
) as v_table25 on v_table74.program = v_table25.program
答案 1 :(得分:1)
select program, event
into #temp --------------------------------check here
from OMEGA.HP
inner join POM.GT
on program = substring(name,7,4)
where LENGTH(name)= 25
答案 2 :(得分:0)
使用公用表表达式(CTE):
class ViewController: UIViewController, UICollectionViewDelegate, UICollectionViewDelegateFlowLayout {
@objc(collectionView:layout:sizeForItemAtIndexPath:)
func collectionView(_ collectionView: UICollectionView,
layout collectionViewLayout: UICollectionViewLayout,
sizeForItemAt indexPath: IndexPath) -> CGSize {
let flowLayout = collectionViewLayout as! UICollectionViewFlowLayout
let totalSpace = flowLayout.sectionInset.left
+ flowLayout.sectionInset.right
+ (flowLayout.minimumInteritemSpacing * CGFloat(4 - 1))
let size = Int((collectionView.bounds.width - totalSpace) / CGFloat(4))
return CGSize(width: size, height: size)
}
}