What have you tried, and what was the result? Based on the few snippets above, it looks like it should work.
An important follow-up question would then be... How have you sanitized $IDs to protect against SQL injection attacks and/or just plain SQL errors due to malformed, user-supplied data?