Can you take Ambien (zolpidem) for sleeping pill, knowing theat you were diagnose with sleep apnea? Would it have a side effect?

Apnea still there. A major concern is still death. If you have an obstruction while you sleep that can prevent quality or deep sleep, the risk of dying still exists, and may be worse. By taking ambien, (zolpidem) you are forcing sleep and may prevent you from waking up from the obstruction. You should treat the problem, not the symptom.
Yes. Ambien (zolpidem) will not affect your sleep apnea directly . It will induce sleep. It is accepted by aasm to be use in studies. Beware on significant lung problems.