"Knowing him had nothing to do with it," Miles said. "Friendship doesn't enter your mind at times like that. I'm just trying to win the game. I really didn't gain anything from knowing him back then."
It was the Cardinals' second straight extra-inning win after taking Saturday's game 7-6 on a 10th-inning home run by Albert Pujols. St. Louis dropped the first game of the series before taking the final three to head into the All-Star break nine games above .500.
Lidge (0-3), who blew the save a night earlier, opened the 12th by hitting David Eckstein with a pitch and giving up a single to So Taguchi. He then retired Pujols and Scott Rolen before Miles' grounded his go-ahead hit down the left field line.
Miles also had an RBI single off Lidge in the ninth inning Saturday.
"I don't know how he hit the ball," Lidge said. "I guess somehow it went off the end of his bat and shot down the line. I'm disappointed."
Miles said the two roomed together years ago when they were in the Astros minor league system and that they remain close.
Braden Looper (4-1) got the win after pitching out of trouble in the 10th inning. He allowed a double to Mike Lamb before hitting Chris Burke and walking Lance Berkman to load the bases. Looper struck out Preston Wilson and Jason Lane to end the inning and then got through the 11th. Josh Hancock got the final three outs for his first save.
Astros manager Phil Garner had used his entire bench by the 11th inning and was forced to use to pitching ace Roy Oswalt, who had four hits on the season, as a pinch-hitter. With two outs, Oswalt hit a grounder down the left field line for what looked to be a double.
But the Cardinals pulled off a successful appeal, and umpire Bob Davidson ruled that Oswalt missed first base on his way to second -- ending the inning.
Oswalt thought he tagged the base, but Garner thought he missed it.
St. Louis had a chance to win it in the 10th, with runners at first and third, but Juan Encarnacion grounded into a double play to end the inning.
"I'm going to have to review this game to believe we won it," Cardinals manager Tony La Russa said. "It was very close all the way. Both teams did heroic things to keep in it."
Houston tied it at 5 in the ninth off closer Jason Isringhausen on Craig Biggio's sacrifice fly. The Astros trailed 5-2 before Burke's two-run homer in the eighth inning got them within a run.
Scott Rolen gave the Cardinals that advantage when he capped a four-run eighth inning with a three-run homer.
St. Louis starter Chris Carpenter allowed six hits and four runs, two earned. He struck out seven and walking two in his longest outing since April before being replaced by Isringhausen one batter into the ninth.
"I had great stuff," Carpenter said. "It was the best stuff I've had all year."
The Astros grabbed a 2-1 lead in the sixth with the help of starter Andy Pettitte's bat. Pettitte led off with his fifth career double and third the season. It was just the second hit for the Astros, and the first since a single by Brad Ausmus in the third.
Pettitte advanced to third when a pitch by Carpenter bounced off catcher Yadier Molina's glove and nearly flew into the Astros dugout. Lamb tripled to score Pettitte and Burke followed with a run-scoring double.
Carpenter didn't allow a hit until a single by Ausmus in the third and recovered from his rough sixth inning to face the minimum in the seventh.
Pettitte tied his season high for strikeouts with eight and walked one while allowing seven hits and three runs. He was replaced by Wheeler after giving up a pair of singles in the eighth.
"We're battling, we're battling hard," Pettitte said. "It just seems like right now everything we do is going wrong. We're making some bonehead plays a little bit. We need to tighten that up."
Pettitte retired 12 out of 14 batters after giving up a double to Edmonds to lead off the second inning. He only allowed one hit in that span as Pujols reached on an error by Burke.
In the sixth, Pujols singled before Pettitte retired Rolen, Encarnacion and Jim Edmonds to end the inning. He followed with a perfect seventh.
- After the All-Star break, Houston has an 11-day, 10-game road trip. After that the Astros will play 15 of 21 at home.
- The Cardinals play only seven of the 19 games at home.
- Houston is tied with the Mets and Padres for most extra-inning games played this season with 11.