createCommand sql query not working in plugin Hi I have a plugin which I am running an sql statement from.

$users = craft()-&gt;db-&gt;createCommand("SELECT craft_users.id as userId, craft_users.firstName, craft_users.lastName, craft_users.email FROM craft_users INNER JOIN craft_content on craft_users.id = craft_content.elementId WHERE craft_content.field_interests LIKE '%\"8948\"%'");


The query is not returning the expected results from the createCommand function in fact it returns an empty array. But if I run it directly in the database it works perfectly and returns the entries.

I also tried building this with the query builder but it was throwing errors and not finding the user table.
Thanks to @carlcs for pointers managed to get this working with the following:

$criteria = craft()-&gt;elements-&gt;getCriteria(ElementType::User);
$criteria-&gt;limit = NULL;

$query = craft()-&gt;elements-&gt;buildElementsQuery($criteria);
$params = array(
    ':interest' =&gt; '%"8948"%',
);
$query-&gt;andWhere("field_interests LIKE :interest", $params);
$result = $query-&gt;queryAll() ;