2 Samuel 5:17-19 (KJV)
17 But when the Philistines heard that they had anointed David king over Israel, all the Philistines came up to seek David; and David heard of it, and went down to the hold.
18 The Philistines also came and spread themselves in the valley of Rephaim.
19 And David enquired of the Lord, saying, Shall I go up to the Philistines? wilt thou deliver them into mine hand? And the Lord said unto David, Go up: for I will doubtless deliver the Philistines into thine hand.
The Lord Was With David While In War
David also slew the Syrians in war, which were also against him, after sending out his men in “a thousand chariots, and seven hundred horsemen, and twenty thousand footmen.” (2 Samuel 8:4)