This mysql statement is not correct and generating syntax errors

can anyone give me pointers on fixing it

SELECT ff.field_survey_value FROM {field_data_field_survey} ff JOIN {node} n ON n.nid = ff.entity_id WHERE n.uid = 1 AND n.type = 'article'

Comments

nevets’s picture

Seeing the error and your code would help.

somes’s picture

Heres the error

#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 '} ff JOIN {node} n ON n.nid = ff.entity_id WHERE n.uid = 1 AND n.type = 'article' at line 1

and the query
SELECT ff.field_survey_value FROM {field_data_field_survey} ff JOIN {node} n ON n.nid = ff.entity_id WHERE n.uid = 1 AND n.type = 'article'

nevets’s picture

How are you invoking the query, I would suspect you should be using db_query().

somes’s picture

Im running it directly in the SQL command window of phpadmin

I took the template from the unit testing of the commerce module as I need to access some custom fields on a node in this case article but i need a join on the tables -

I cant figure it out - Im missing something very trivial

tks
M

somes’s picture

SELECT ff.field_survey_value FROM field_data_field_survey AS ff JOIN node AS n ON n.nid = ff.entity_id LIMIT 0 , 30

this works for me

M

nevets’s picture

The {} braces are a Drupal feature for table names to support prefixing. They are only valid when using the Drupal db API.