0

I have a query:

    select daa.*
    from Dataa daa
    where not exists (select row() from Stuff)

Basically, when Stuff has data in it, the query returns nothing. However, when Stuff is empty, the query returns everything in Dataa. I need to rewrite this query with the same behavior, but without the exists keyword, so that I can translate it into Relational Algebra.

Some resources I've looked at are:

Converting NOT IN to NOT EXISTS http://mlwiki.org/index.php/Translating_SQL_to_Relational_Algebra#EXISTS_in_the_Where_Clause_.28by_example.29

1 Answers1

0

There are few way to write it without Exists

select daa.*
from Dataa daa
where (select 1 from Stuff limit 1) is null

select daa.*
from Dataa daa
where (select count(*) from Stuff) = 0

select daa.*
from Dataa daa
left outer join (select 1 one1 from Stuff)j on 1=1
where j.one1 is null

but I do not see what exactly is the problem with that keyword.

Antonín Lejsek
  • 6,003
  • 2
  • 16
  • 18