Hello there..
I Was working on some sumary report querys from taxonomy and fields, so I was doing this:

$query = "SELECT ttd.tid, ttd.name, SUM( IF(g.field_genero_value = 'Masculino',1,0))m , SUM( IF(g.field_genero_value = 'Femenino',1,0))f, SUM( IF(g.field_genero_value = 'LGTBI',1,0))l, SUM( IF(g.field_genero_value = 'N/A',1,0))n
    FROM  {node} as n
    INNER JOIN {field_data_field_genero} AS g ON n.nid = g.entity_id
    INNER JOIN {taxonomy_index} AS ti ON n.nid = ti.nid
    INNER JOIN {taxonomy_term_data} AS ttd ON ti.tid = ttd.tid
    WHERE n.status = 1 AND n.type = 'alertas'
    GROUP BY ttd.tid"

so far so good, but I realized that I need a repetition for some fields on the node, including "field_data_field_genero" and some taxonomy terms as well, logically I installed Field collection for this matter, but then, I don't get how can I Join the fields with the statement about with the nodes.

So my cuestion is, where can I find some Info. to understand the mysql tables logic for fields collectios
It is not my intention to make someone do my work for me, but I need a point for beguin to understand the implicit logic

Sorry about the spelling...

And thaks anyone can help me

Comments

jmuzz’s picture

Issue summary: View changes
Status: Active » Fixed

If you look at the field data on the host entity the "field_fieldname_value" column corresponds to the "entity_id" column in the inner field.

Hope this helps.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.