We know that in production code SELECT *
is bad.
However, I will often write SELECT *
in my SQL answers when
- The OP failed to include their SQL (so I've got nothing to copy and paste)
- The OP's question is really answered with the
JOIN
orWHERE
- There's no syntax in my answer like
GROUP BY
thatSELECT *
can easily conflict with. [A]
Recently someone thought an answer of mine would be improved if I removed the SELECT *
.
Obviously, I think it is acceptable to answer with SELECT *
but I can't say why.
[A] I'm pretending that MySQL and its treatment of GROUP BY don't exist
SELECT ... FROM
also makes sense even to SQL newbies.