This incident is recorded, with a few differences, in all four gospels. In the Synoptics (Matthew, Mark, and Luke), the incident occurs after Jesus’s triumphal entry into Jerusalem, just a few days before his death, and so at the end of his ministry. In John, the incident takes place at the beginning of his ministry. Here are the four texts :
Matthew 21:12-13 : Then Jesus entered the temple and drove out all who were selling and buying in the temple, and he overturned the tables of the money changers and the seats of those who sold doves. He said to them, “It is written, ‘my house shall be called a house of prayer’ ; but you are making it a den of robbers.”
Mark 11:15-17 : And he entered the temple and began to drive out those who were selling and those who were buying in the temple, and he overturned the tables of the money changers and the seats of those who sold doves ; and he would not allow anyone to carry anything through the temple. He was teaching and saying, “Is it not written, ‘My house shall be called a house of prayer for all the nations’ ? But you have made it a den of robbers.”
Luke 19:45-46 : Then he entered the temple and began to drive out those who were selling things there ; and he said, “It is written, ‘My house shall be a house of prayer’ ; but you have made it a den of robbers.”
John 2:14-16 : In the temple he found people selling cattle, sheep, and doves, and the money changers seated at their tables. Making a whip of cords, he drove all of them out of the temple, both the sheep and the cattle. He also poured out the coins of the money changers and overturned their tables. He told those who were selling the doves, “Take these things out of here ! Stop making my Father’s house a marketplace !”