Get the titles of the nodes whose node IDs are contained in a field
A few remarks:


You said that $node-&gt;field_xlnum[0]['value'] contains a list of nid separated by comas so you don't need to explode it in order to use them in a IN clause. If you do so, $attr will be an Array().
You put test as an argument in your query, isn't this a variable $test or a string 'test'
You should better use db_placeholders for putting multiples values inside a IN.

$attr = explode(",", $node-&gt;field_xlnum[0]['value']);
db_query("SELECT n.nid, n.title
  FROM {node} n
  WHERE n.nid IN (" . db_placeholders($attr, 'int') . ")
  AND type = %s 
  ORDER BY n.created DESC", $data, 'test'
);