Assuming $new_lang
holds the desired two letter language code (e.g. ‘fr’), you can do this:
global $sitepress;
$current_lang = $sitepress->get_current_language(); //save current language
$sitepress->switch_lang($new_lang);
//...run query here; if you use WP_Query or get_posts make sure you set suppress_filters=0 ...
$sitepress->switch_lang($current_lang); //restore previous language
For more info, check http://wpml.org/documentation/support/achieving-wpml-compatibility-for-your-themes-and-plugins/debugging-theme-compatibility/