ST. LOUIS (AP) — Brett Wallace welcomes a chance to face the team that drafted him in the first round only to ship him off for a proven player.

The St. Louis Cardinals took Wallace with the 13th-overall pick out of Arizona State in the 2008 draft but gave him to Oakland a year later as part of a trade to get Matt Holliday. Wallace had four hits against St. Louis on Wednesday night, but it wasn't enough for the Astros.

Matt Carpenter hit a two-run home run off lefty Wesley Wright (0-3) and Holliday drove in two with a two-out hit to help the St. Louis Cardinals beat the Houston Astros 5-4. Seth Maness (5-1) pitched two innings for the win

"It's always fun to do it against them because I know a lot of the guys and we've been here quite a bit," Wallace said. "It's a good place to hit. It's a good place to play. The fans are awesome. It's a great environment."

Wallace who was demoted in April to the minor leagues before returning to Houston on June 25 to face St. Louis, is 7 for 18 with five RBIs and four runs in the four games against the Cardinals this year. In the past six games overall, he has 10 hits in 24 at bats, though he's hitting just .225 with 11 RBIs this season.

"He continues to swing the bat, continues to use the whole field," Houston manager Bo Porter said. "You look at the majority of his hits. They're up the middle, they're the other way. He's staying on the ball and hitting with a lot of confidence right now."

Carpenter, headed to his first All-Star game, doesn't seem to have any concerns with his hitting no matter who he faces. The left-hander's batting average is nearly 40 points lower against lefties (.294 versus .333 against right-handers), but four of his nine home runs this season have come against southpaws.

Maness gave up two hits and a run in two innings of relief. He struck out three.

Edward Mujica earned his 25th save in 26 tries. He has appeared in six consecutive games, going 1-1 with four saves.

Houston starter Jordan Lyles gave up four runs and six hits in 6 1-3 innings. He struck out two and walked two. Lyles hasn't won a game since beating Milwaukee on June 18.

Cardinals starter Shelby Miller used 94 pitches to labor through five innings. He gave up three earned runs, walked five and struck out five. He had a total of six full counts, coming back to strike out Jason Castro and getting Wallace to ground out.

"It was a rough one for me," Miller said. "I didn't have anything going for me. I couldn't throw strikes or much of anything. I just tried to keep the team in it as much as I could with what I had. It wasn't much, but five innings, three runs and the offense picks you up.

"These guys never cease to amaze me when they go out there and do the things that they do."

Wallace, who had four hits and scored a run, drove in Jose Altuve in the seventh to give Houston a 4-3 lead. His only out was a grounder in the fifth that led to Houston's third run.

Holliday's single in the fifth tied the score at 3-3. His slap to right field drove in Cruz and Shane Robinson, who had a pinch hit single in place of Miller.

Allen Craig walked to open the second and scored on Matt Adams' single. Adams has five RBIs in in his past six games.

The Cardinals swept their five-game homestand with three victories over Miami before taking both against Houston. The home sweep comes on the heels of a 7-11 stretch that included three wins over the Chicago Cubs, who host the Cardinals in a four-game set starting Thursday.

"This is a huge five-game stretch for us to win, come out here and win all these games at home, to get on a roll right before the All-Star break," Carpenter said. "Hopefully we can continue it in Chicago."

Chris Carter hit his 18th home run just over the right field fence to open the second. Houston then took a 2-0 lead on Wallace's single, two walks and an error. It took a 3-1 lead after Castro hit a ground-rule double and J.D. Martinez drove him in with a single in the fifth.

Game notes: Cardinals C Cruz got his third start in the past four games in place of All-Star catcher and league-leading batter Yadier Molina who is nursing a sore right knee. He's gone 3 of 9 in that span. ... Molina struck out as a pinch hitter in the seventh. ... Porter said after the game the Astros will call up one of their top prospects, 23-year-old right-hander Jarred Cosart, to make his major league debut Friday at Tampa Bay. Dallas Keuchel will be pushed to Saturday with Erik Bedard starting on Sunday. . The Astros have lost 13 of their past 15 games against their former NL Central division rivals.