I apologize if I ask for something obvious, but I am asking because I could not find a simple answer anywhere.

I know how to work with these tables in the PHP Drupal code, which built-in functions to use, etc., but for some reasons, I have to write a literal SQL query to the Drupal database.

That's why I'm asking what condition I need to use in the SQL query to connect the field_data_field_abc table with the node table?

If the data in the field_data_field_abc table contains the entity_type column with the value "node", can I do something like this:

FROM node n
LEFT JOIN field_data_field_abc abc ON n.nid = abc.entity_id
WHERE abc.entity_type = 'node'

1 Answer 1


Yes, you are right :)

In general, for each table from field_data_field_* family, if its entity_type is equal to the "node" value, then it can be associated with the n.nid from the node table and if the entity_type is equal to the "user" then the entity_id value is associated with the uid value from the users table.

I hope it will help somebody.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.