I can't seem to figure out, are you not allowed to chain db_select methods?
$nid = db_select("node", "n")
->fields("n", array("nid"))
->condition("f.entity_type", "node", "=")
->condition("f.deleted", 0, "=")
->condition("f.field_products_product_id", $entity->product_id, "=")
->addTag("node_access")
->join(
"field_data_field_products",
"f",
"f.entity_id = n.nid"
)
->execute();
I have the above, and it just won't work it keeps erroring on the join. Basically I want to do
SELECT nid FROM node JOIN field_data_field_products ON entity_id = nid WHERE ...