getting node items by taxonomy
You need to use the EntityFieldQuery instead of the SelectQuery that db_select uses. You should do something like this:

$query = new EntityFieldQuery();
$result = $query
  -&gt;entityCondition('entity_type', 'node', '=')
  -&gt;entityCondition('bundle', 'slider', '=')
  -&gt;fieldCondition('fieldname', 'tid', $tid)
  -&gt;propertyOrderBy('changed', 'DESC')
  -&gt;range(0, 4)
  -&gt;addTag('node_access')
  -&gt;execute();


The results will be an array of objects containing the nid and vid.

Read more about the fieldCondition