0

I have this table: enter image description here

How I can write instruction if, which will check the records stored at the same time (in my table it is column created_at). For example:

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'
}
major697
  • 139
  • 1
  • 2
  • 15

1 Answers1

0

Several options for this. Here's a version using 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)
sgeddes
  • 62,311
  • 6
  • 61
  • 83