My general approach is:
1. If it is a coding problem, I try to come up with my own way so as not to just copy what someone else has done. I have found that makes me learn more about the problem and the different solutions. If I still can't figure it out, then I do some research.
2. If it is an emergency or bug, I first Google or otherwise research the issue, so that I err on the side of safety, i.e., not going down blind alleys that might waste time or make things worse.
In either case, I always compile the sources that helped me and reference them in the code that I change, to give proper credit.
A SQL query walks into a bar and sees two tables. He walks up to them and says Can I join you?