A few years ago, I spent about thirty hours a week working at a supermarket while attending community college part-time. I doubt I learned much at the second of those two that hasn't already been noded here by someone more knowledgeable than I, but I did learn some very interesting things at the supermarket that might be useful the next time you shop for fresh produce.
E2 already has excellent nodes explaining How to choose fresh fruit and When best to purchase fresh vegetables. As good as they are at describing the optimal seasonal and physical characteristics of good produce, they don't really explain where to get those high-quality fruits and veggies. Ideally, you should have your own garden, and, failing that, access to a local farmer's market. Most people don't, and have little choice but to find their produce on supermarket shelves.
Ugly at the top:
The first thing you should know about supermarket produce is rotation. Generally speaking, stocks of all perishable items are rotated in retail stores, and I would assume this to be true for wholesalers as well. Old product gets rotated to the front/top of the shelf/stack, with the newer, fresher stuff placed behind/beneath it. You don't want food to rot before you can sell it.
It's easy to see when stocks of, for example, milk have been rotated, since each container has a date stamped on it. Produce isn't dated, of course, and requires a bit of judgement to find the good stuff. Nonetheless, if the produce guy has been doing his job, the freshest fruits and vegetables should be at the bottom of the stack. Just make sure you don't topple it while you're digging. He probably isn't getting paid enough for what he already does.
What happens to all the produce that goes bad before they can sell it?
Most of it, unfortunately, goes to waste. At the supermarket where I worked, meat and baked goods were sent to a local food bank if they hadn't been sold within a certain time period, but before they became inedible. (An aside: I don't think this is done anymore. This particular supermarket was locally owned. A few months before I stopped working there, it was bought out by a huge international conglomerate that instituted major changes in the name of "efficiency.") This wasn't the case for produce. Large amounts of unsellable goods went into the dumpster or the grinder (a large-scale version of the garbage disposal you probably have in your sink) every night. Occasionally, when peaches were in season, this proved very enjoyable for those assigned the task of closing down the produce department. A half-mushy peach couldn't be sold, but the other half was bound to be deliciously sweet. When the managers had gone home, we'd sit in the back room, devouring dozens of overripe fruit and throwing the bad parts in the dumpster as we ate. Also, a woman who made deliveries to the store lived on a horse farm, and we'd give her whole boxes of apples that'd otherwise have been thrown out. Nobody wants to waste food, and given the chance they find some use for it, but a supermarket is designed to maximize profits, not to conserve resources.
Lettuce, cucumbers and other salad vegetables at the store where I worked weren't just thrown out when they became unsellable. The supermarket had a salad bar next to the produce department, and half-bad greens were dissected and sorted by the employees responsible for stocking it. Much of what people paid three dollars a pound for and ate on their lunch breaks was days old, cut from vegetables with enough wilted or mushy sections that they'd never have been bought whole. I don't know what happens to these veggies at stores without salad bars; presumably they're just thrown out.
Making it look good:
Real food doesn't look anything like the glistening forms found in advertisements. But people are accustomed to that look, and they're naturally inclined to buy things that look healthy and shiny, regardless of whether they actually are. Long before arriving at the store, the produce had been sorted for uniform size and shape, and coated with a supposedly harmless (but very artificial-looking) layer of wax if its particular species allowed such treatment. Waxed fruit don't require any further maintenance, but vegetables do.
Leafy greens tend to wilt if not kept moist and are periodically sprinkled with water to prolong their shelf life. There's nothing wrong with that, but the sprinkler was applied indiscriminately to any vegetable that the water wouldn't ruin, even sealed bags of carrots. In the words of my manager, "it looks more natural that way." It also does a good job of concealing flaws. Shiny doesn't necessarily mean healthy - don't let a film of water entice you into buying a pepper or radish until you've carefully inspected it.
Stalk-type vegetables such as celery and romaine lettuce need to be watched and trimmed regularly while on retail display, removing any brown spots. The butt of the stalk goes brown easily, and many of these vegetables need to be trimmed at that end before display and daily while they're for sale. Thus, the longer a stalk of romaine or celery has been there, the shorter its butt is likely to be, providing a good indication of relative freshness in these plants.
Not paid enough to know anything:
Produce clerks are essentially unskilled laborers. Having spent a considerable amount of their time with produce, they usually learn how to tell whether something is fresh or rotten, and most will reply honestly if you ask them. Very few, however, know anything at all about the taste of and cooking styles appropriate to the more exotic plants that they find themselves stocking. Neither do their managers, who tell them to answer customer's queries any way they can. Many will just make something up (Star fruit? Oh, that's from Mexico or something. You can peel off the skin and put it in your salad.) to get a persistent customer off their backs. I know - I used to do it all the time, as did nearly all my coworkers. If you really want to know what to do with some esoteric fruit or vegetable, Google will be a much more reliable source of information than someone working at the supermarket.
Beating the odds:
I was a jack of all trades at that supermarket. On weekends, they'd leave me in charge of the receiving dock, where I'd review and sign invoices for the shipments that arrived. I can tell you from personal experience that supermarket produce is sold at a huge markup from the time it arrives in a refrigerated trailer to its final pass under a cashier's scanner. Every rotten cucumber that lands in the dumpster is a minus on the manager's balance sheet. It's in their interest to get that cucumber into a customer's cart before that can happen, by any (legal) means necessary. Whether it goes bad the day after you take it home or makes a delicious salad a week later, it's all the same to them. The odds are stacked against you, the customer. Maybe now you know enough to reverse them.