know which side one's bread is buttered on

[know which side one's bread is buttered on] {v. phr.} To know whocan help you and try to please him; know what is for your own gain.

Dick was always polite to the boss; he knew which side his bread wasbuttered on.