我如何编写指令if
,它将检查同时存储的记录(在我的表中是列created_at
)。
例如:
if(created_at for record where key(it's column)='stan' it is the same as created_at for key='stan_key' {
return records where key='stan'
}
答案 0 :(得分:0)
有几种选择。这是使用exists
的版本:
select *
from yourtable y1
where y1.key = 'stan' and exists (
select 1
from yourtable y2
where y2.key = 'stan_key' and y1.created_at = y2.created_at)