db_select throws PDOException Trying to do a simple query from a table called 'raffles' under the drupal database.

It is not a complex query, Just trying to get all sets from drupal.raffles

$query = db_select('raffles');
$query-&gt;execute();
$result = $query-&gt;fetchAssoc();
dpm($result);


The error

PDOException: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'FROM raffles raffles' at line 1: SELECT FROM {raffles} raffles; Array ( ) in raffle_create_form() (line 8


From the error, the query has the table name twice, and is probably what is causing the error. maybe im doing something wrong? There is not much information related to this on the api page.

Any help would be gladly appreciated.

Thanks.
You haven't selected any fields:

$result = db_select('raffles', 'r')
  -&gt;fields('r', array('foo', 'bar'))
  -&gt;execute()
  -&gt;fetchAll();


If you want to select all the fields, then use the following code.

$result = db_select('raffles', 'r')
  -&gt;fields('r')
  -&gt;execute()
  -&gt;fetchAll();


Incidentally, the second raffles is a valid alias and not related to the problem.