It's a complicated answer with a fair amount of debate; there have been a few studies about it. Full disclosure, I'm hardly an expert, but I'll tell you what I can.
They certainly don't like getting hooked. Most of the time they survive, but sometimes they don't.
It depends on a lot of things: how resilient the particular species is, the extent of their injuries, how long they were exposed to air, and where they sit in that particular ecosystem.
Generally, if you hook one, and they don't damage their mouth badly in the reeling process, and they're not in the air that long, they're fine. They'll swim away and go on to feed fine and survive.
If you get a thrasher, and they really put up a fight and the hook messes them up, to the point where they won't be able to eat, it's best to kill them quick, take them home and cook them. If they thrashed so hard that they tire themselves out a lot, and they'll likely end up getting eaten by bigger predators, again, just put the fish out of it's misery quick, and cook them
With certain fish, you have to put them back properly. With trout, especially after they've been out of the water for a while and are tired, you can't just toss them back in; you have to grab them with both hands and rock them back and forth in the water a bit before you let go. They might just float away with the current, but they'll usually bounce back quick. If they're at risk for being eaten by any predators in that area, it's best to take them home. Sunfish, while small, are tough as nails. They put up a good fight, and are VERY resilient. You can just toss them back in and they'll very likely be fine. But they're also at risk of being nabbed by any bass in the area in their weakened state, so you have to take that into account.
It's important to be conscious of those things, and weigh one against the other if you catch and release.
Bear in mind, this is just my experience, and the more experienced fisherman on the board might know more
---------- Do you ask that question often?