Can you please explain that how you are using your short code?
However, apparently I suspect that you are trying to define different IDs with same repeating attribute (i.e. id=xxx id=xx id=999 and so on). The latest occurrence of the same attribute, overrides the previous one.
However, if you are not doing this, but expecting $atts as an attribute name of your comma-separated list of ids (i.e. id="1,2,3,4"), please change $atts to $atts['id'] in line after global $wpdb. Please use correct attribute name (the same as you used to pass-on the ids).