Qdabra's QueryDB web service was designed especially for this purpose and I would recommend checking it out if you might be doing this type of work from time to time:
http://www.youtube.com/watch?v=odt7QaPuVDo
If it's just for this one scenario and you are somewhat handy with code, you may also want to check out this post I made a while back:
http://www.infopathdev.com/forums/p/9467/33496.aspx#33496