Same-store sales at BJ's Wholesale (NYSE:BJ) rose 5.3% for the month of June. That's not too bad for a company that sits behind Costco (NASDAQ:COST) and Wal-Mart's (NYSE:WMT) Sam's Club in the warehouse club industry.

This is one case where rising gas prices helped. Out of its 5.3% increase, management attributed more than a quarter, or 1.4% of the total, to gas sales. According to the company, it is generally priced below average in that particular market. But accepting a lower profit on gas sales helps drive traffic into its stores.

There was good news on other fronts as well. Traffic increased by 2%, and the average transaction rose 3%, excluding gasoline. So more people were shopping and spending more money -- a very nice combination.

Food is also an important component, accounting for about 60% of BJ's general sales. This, too, brought good news. Food sales increased 6%. This was the strongest increase in two years, and given rising food prices, I expect this to continue, as consumers look to save money by buying in bulk.

BJ's has a few advantages over its rivals. It accepts coupons from manufacturers, while its competitors do not, and it sells certain items in smaller packages. It also accepts more credit cards than Sam's or Costco warehouses. The latter only accepts American Express.

I believe rising gas and food prices will play to BJ's strengths. It is able to offer these at discounts to traditional grocers and gas stations. Doing this increases store traffic, and customers also may spend more on other items, like big-screen televisions. This could in turn increase margins, which is one ingredient the company is missing today.

Related Foolishness:

Wal-Mart is a Motley Fool Inside Value recommendation. Costco is a Motley Fool Stock Advisor selection. Both newsletters beat the market and both are available for a free 30-day trial.

Fool contributor Larry Rothman is happy to receive feedback, and promises to read it when not being wrestled by his three children. He doesn't have any positions in the companies mentioned.