"King Laios and Queen Jocata of Thebes learned from an oracle that their newborn son will kill his father and marry his mother"
Horrified by this prediction, they gave their baby to a shepherd with orders to leave the infant to die on a lonely mountainside.
Instead of abandoning him, the shepherd gave him to a Corinthian shepherd, who in turn gave the baby to the childless king and queen of Corinth. They named him Oedipus
Oedipus immediately guessed that the answer to the riddle was "man". And so the Sphinx let Oedipus go and Thebes was saved
Years later when Oedipus found out about the prophecy, he ran away thinking the king and queen of Corinth were his real parents. In the course of his lonely wanderings, he encountered an arrogant old man who tried to run him off the road with his chariot. Because honor was at stake, the two men fought, and Oedipus killed the stranger.
At the outskirts of the city, he encountered the Sphinx. The Sphinx had been menacing Thebes and asked Oedipus a riddle, if he answered it right he was free to go, but if he answered it wrong she would eat him.
The riddle went like this: "What creature goes on four legs in the morning, two legs in the afternoon, and three legs in the evening
When Oedipus arrived in Thebes, the city he been born, the people welcomed him as their savior. Since Laios, their king, had recently been killed, the Thebans offered Oedipus their throne and the widowed queen, Jocasta, as his bride. So Oedipus became king of Thebes, married Jocasta, and had four children withher: two sons, Polyneices and Eteocles; and two daughters, Antigone and Ismene.