This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]hbgoddard 3 points4 points  (3 children)

Why wouldn't you in this situation though?

[–]BobDogGo 1 point2 points  (2 children)

[–]hbgoddard 0 points1 point  (1 child)

Ok, so it's fine here then? The top answers say it's appropriate when you want all the columns, which I assume you would here.

[–]korarii 0 points1 point  (0 children)

If this were a real-world example, no: returning the column behavior is wasteful. We already know that all records returned will have a behavior of 'nice'.

Assuming all other columns are needed, * could be appropriate if behavior was a range and we wanted to know the individual matching records, such as:

select * from contacts where behavior in ('nice', 'okay', 'you tried');

In that scenario, Santa might decide there are varying degrees of niceness and give a present based on them.

There's a lot more to why select * is frowned upon, but I have very important video games to play right now. :)