sql - what is the difference in writing styles of these 2 queries? -


i using ms sql server 2012:

the 2 queries are:

1:

with cte (  <some code> ) delete p table p join cte on p.id=cte.id , p.date>cte.date 

2:

with cte (  <some code> ) delete p table p join cte on cte.id=p.id , cte.date>p.date 

the difference in 2 queries writing join condition of either of table columns first.

how should decide efficient or correct?

the equality = operator symetric. flipping order of operands doesn't have functional or performance impact.

the greater (>) operator, on other hand, is, of course, not symertic. p.date>cte.date , cte.date>p.date functionally different, , should choose correct 1 according business logic, regardless of performance. no matter how fast delete statement runs, if it's deleting wrong thing, it's pretty useless (not mention down right harmful).


Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -