In any case, it is strongly encouraged to the API for submitting your query, either extbase or, if it has to be, the old system, pibase.
In pibase, you can use pi_getPidList($pid_list, $recursive) to get the recursive list of pids and then pass it to your exec_SELECTquery()
(...or, if you absolutely need to - but you really shouldn't - build your SELECT query with WHERE pid IN ($pid_list))
For extbase, I found this workaround, maybe there is something newer already.