I know the obvious answer is to simply not go.
That may be "obvious", but I think a better way is to go fairly regularly! The more commonplace it seems to your children, the less likely you'll see unusual behavior. We started taking our son to restaurants at a very early age (about 3 months old), and continue to do so 3 years later. He generally does very well, and he's made several friends among the staff at the restaurants we frequent most often.
However, going often isn't really enough. There are other considerations to keep in mind.
One of the biggest ones, mentioned in several of the answers already posted, is picking a "good" restaurant. By "good", I mean one that is at least somewhat accommodating to children (children's menu, crayons available, high chairs/booster seats/baby-seat slings are available, etc.), and also one where some degree of noise is unlikely to draw any notice.
I wouldn't take my son to an intimate setting, where everyone is talking quietly and soft incidental music is being played. Instead, we go to restaurants where loud conversations are common, and the general ambient noise level is loud enough that a child joking about bodily functions is likely to go unnoticed.
Another important factor is the food they offer. If there's nothing there your kids will enjoy eating, its going to be a struggle no matter how well behaved they are. If a place doesn't offer a children's menu, or doesn't offer any of my son's favorites, we don't go (alas... this means I only rarely get to enjoy Chinese food!).
I also suggest bringing entertainment.
I've seen people bring portable DVD players to restaurants, set them up on the table in front of their child, and then proceed to ignore them for the duration of the meal. I am NOT suggesting that you do this!
Instead, we bring a small backpack filled with supplies (diaper changing gear) and toys. Sometimes he's content to color with the crayons and placemat the restaurant provides, but other times he picks some toys out of the bag, and happily plays with them.
At home, we have a strict "no toys at the dinner table" policy, but this rule is suspended at restaurants.
The only rules we enforce at the restaurant are:
- No throwing
- We use our "quiet" voices (how quiet this is depends upon the ambient noise level in the restaurant)
- No disturbing other patrons in the restaurant
The last one is sometimes the hardest, but the way we usually address it is "sit facing front!". This is usually reserved for whenever he starts to peer over the back of his seat to look at the people behind him (assuming someone is at the adjoining booth/table).
Any infringement of the "no throwing" rule results in immediately losing whatever it is he threw, and a stern warning (we've never had a second offense in one sitting).
If he starts to get too loud, we remind him to use his "quiet" voice. Sometimes it takes 2 or 3 reminders, but rarely more than that.
On the (very rare!) occasion that he starts screaming/crying uncontrollably, one of us will ask him if he needs to go outside with one of us. I think there was only one instance where that didn't immediately calm him (I did follow through by taking him outside the restaurant until he had calmed down).