Search code examples
sqlsql-serveroracle-databasequery-optimizationansi-sql

Is there a way to write joining where clauses without AND operator?


Just for curiosity, is there a short/pretty way to write classic SQL where clauses without the AND operator for joining tables?

Classic:

select * 
from table1, table2, table3 
where table1.fkId = table2.id 
  and table1.fkId = table3.id

It would be nice to have something like:

select * 
from table1, table2, table3 
where table1.fkId = table2.id = table3.id

For info, I am using Oracle and SQL Server databases most of the time.


Solution

  • You can use the ALL operator for the same

    select * from table1, table2, table3 
    where table1.fkId=ALL(table2.fid,tables3.fid..)