On hearing this, David sent Joab out with the entire army of fighting men.
The Ammonites came out and drew up in battle formation at the entrance to their city, while the kings who had come were by themselves in the open country.
Joab saw that there were battle lines in front of him and behind him; so he selected some of the best troops in Israel and deployed them against the Arameans.
He put the rest of the men under the command of Abishai1 his brother, and they were deployed against the Ammonites.
References for 1 Chronicles 19:11
Joab said, "If the Arameans are too strong for me, then you are to rescue me; but if the Ammonites are too strong for you, then I will rescue you.
Be strong and let us fight bravely for our people and the cities of our God. The LORD will do what is good in his sight."
Then Joab and the troops with him advanced to fight the Arameans, and they fled before him.
When the Ammonites saw that the Arameans were fleeing, they too fled before his brother Abishai and went inside the city. So Joab went back to Jerusalem.
After the Arameans saw that they had been routed by Israel, they sent messengers and had Arameans brought from beyond the River, with Shophach the commander of Hadadezer's army leading them.
References for 1 Chronicles 19:16
When David was told of this, he gathered all Israel2 and crossed the Jordan; he advanced against them and formed his battle lines opposite them. David formed his lines to meet the Arameans in battle, and they fought against him.
References for 1 Chronicles 19:17
But they fled before Israel, and David killed seven thousand of their charioteers and forty thousand of their foot soldiers. He also killed Shophach the commander of their army.
When the vassals of Hadadezer saw that they had been defeated by Israel, they made peace with David and became subject to him. So the Arameans were not willing to help the Ammonites anymore.