how using mysql CAST in db_select
You can use the where() method for a SelectQuery:

...
$q-&gt;where('CAST(n.nid AS SIGNED) &gt; :nid', array(':nid' =&gt; 11517));
...


So the choice is yours which type of query to use.