3 ms·
Its usually better to be explicit and use aggregates like MAX or MIN instead of a LIMIT of 1.
by goldenkey 11y ago
Its usually better to be explicit and use aggregates like MAX or MIN instead of a LIMIT of 1.
- degenerate 11y agoCan you elaborate on that with an example? I can't imagine when running MAX() or MIN() could be better than a static digit, so an example would help me understand your comment!
- crishoj 11y agoAs in SELECT MAX(a), c, d FROM t WHERE b=x? MySQL will return a random c and d, not necessarily the c and d from the row with maximum a...
- acqq 11y agoGoldenkey actually posted SELECT c,d FROM t WHERE a=(SELECT MAX(a) WHERE b=X from t) But that post got flagged because he also gave his opinion on the level of understanding the article writer has. The query you posted is actually the one by the article writer.
- crishoj 11y agoI see. Thanks.