0

I'm little question... I think this is only a semantic question... Can anyone explain me real diff on these two query? If there is one...

// #1 - Query with join
SELECT DISTINCT cli.COD_CLIENTE   
FROM CLIENTI cli    
JOIN BANCHE b 
    ON b.COD_BANCA = cli.COD_BANCA    
JOIN SOA_CONO_VISIB cv 
    ON cv.COD_SOCIETA = b.SOCIETA_SOA     
    AND cv.FLAG_ENTITA_OPER = 1     
    AND cv.COD_MACRO_CLASSE <> 'RFE'      
    AND cv.DATA_FINE_OPERATIVITA IS NULL  
WHERE   cv.COD_SOCIETA = '01'  
    AND cv.COD_ENTITA = '00008';


// #2 - Query with implicit join        
SELECT DISTINCT cli.COD_CLIENTE   
FROM CLIENTI cli, BANCHE b, SOA_CONO_VISIB cv 
WHERE cv.COD_SOCIETA = '01'  
    AND cv.COD_ENTITA = '00008'
    AND b.COD_BANCA = cli.COD_BANCA
    AND cv.COD_SOCIETA = b.SOCIETA_SOA     
    AND cv.FLAG_ENTITA_OPER = 1     
    AND cv.COD_MACRO_CLASSE <> 'RFE'      
    AND cv.DATA_FINE_OPERATIVITA IS NULL;
  • 2
    No difference except the second one is more difficult to parse to see if you missed a join condition. In inner joins using the first syntax best to put predicates only referencing one table in the where for clarity. – Martin Smith Apr 03 '15 at 17:05
  • To add to Martin's very correct answer: There will be a difference if you switch to a LEFT or RIGHT JOIN instead of INNER. – JNevill Apr 03 '15 at 17:08
  • @Martin You should definitively post that as an answer. – Sylvain Leroux Apr 03 '15 at 17:09
  • @SylvainLeroux [this is certainly a duplicate](https://www.google.co.uk/#q=difference+ansi+89+92+inner+join+oracle+site:stackoverflow.com) – Martin Smith Apr 03 '15 at 17:13
  • There is no difference. Even statements like "one is more difficult to parse" are really matters of opinion. – David Faber Apr 03 '15 at 17:24

1 Answers1

0

They are exactly the same, with implicit join you have to "manually" do references between tables and, with query that select from many tables, this could be an excessive work.

Here another question like yours, maybe you could find other information.

http://www.stackoverflow.com/questions/44917/explicit-vs-implicit-sql-joins

Marco
  • 705
  • 8
  • 28