Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 321 Vote(s) - 3.39 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Questions every good Database/SQL developer should be able to answer

#21
I've placed this answer because Erwin Smout posted a [answer](

[To see links please register here]

) that was so wrong it highlighted that there is probably a need to specifically guard against it.

Erwin suggested:

>"Why should every SELECT always include DISTINCT ?"

A more appropriate question would be: If someone were to make the claim that: "every SELECT always include DISTINCT"; how would you comment on the claim?

If a candidate is unable to shoot the claim down in flames they either:

* Don't understand the problem with the claim.
* Lack in critical thinking skills.
* Lack in ability to communicate technical issues.

**For the record**

1. ***Suppose your query is correct***, and does not return any duplicates, then including DISTINCT simply forces the RDBMS to check your result (zero benefit, and a lot of additional processing).
2. ***Suppose your query is incorrect***, and _does_ return duplicates, then including DISTINCT simply **hides** the problem (again with additional processing). It would be better to spot the problem and fix your query... it'll run faster that way.


Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through