2

我阅读了一些建议,但无法弄清楚如何使视图生成和显示的查询 - 在 mysql 中有效。{} 中关闭了一些变量,而且我认为查询中有一些表在数据库中不存在。我试图在这里提取一个非常复杂的查询。提前10倍!

SELECT field_data_field_punch_status.field_punch_status_value AS field_data_field_punch_status_field_punch_status_value, users.name AS users_name, users.uid AS uid_1, field_data_field_punch_start.field_punch_start_value AS field_data_field_punch_start_field_punch_start_value, field_data_field_team.field_team_tid AS field_data_field_team_field_team_tid, users.access AS users_access, MIN(users.uid) AS uid, 'user' AS field_data_field_punch_status_user_entity_type, 'user' AS field_data_field_punch_start_user_entity_type, MIN(node_users.nid) AS node_users_nid, 'node' AS field_data_field_punch_end_node_entity_type, MAX(node_users__field_data_field_punch_end.field_punch_end_value) AS node_users__field_data_field_punch_end_field_punch_end_value, 'user' AS field_data_field_team_user_entity_type
FROM 
{users} users
LEFT JOIN {field_data_field_team} field_data_field_team ON users.uid = field_data_field_team.entity_id AND (field_data_field_team.entity_type = 'user' AND field_data_field_team.deleted = '0')
INNER JOIN {taxonomy_term_data} taxonomy_term_data_field_data_field_team ON field_data_field_team.field_team_tid = taxonomy_term_data_field_data_field_team.tid
LEFT JOIN {node} node_users ON users.uid = node_users.uid
INNER JOIN {users_roles} users_roles ON users.uid = users_roles.uid
LEFT JOIN {field_data_field_punch_status} field_data_field_punch_status ON users.uid = field_data_field_punch_status.entity_id AND (field_data_field_punch_status.entity_type = 'user' AND field_data_field_punch_status.deleted = '0')
LEFT JOIN {field_data_field_punch_start} field_data_field_punch_start ON users.uid = field_data_field_punch_start.entity_id AND (field_data_field_punch_start.entity_type = 'user' AND field_data_field_punch_start.deleted = '0')
LEFT JOIN {field_data_field_punch_end} node_users__field_data_field_punch_end ON node_users.nid = node_users__field_data_field_punch_end.entity_id AND (node_users__field_data_field_punch_end.entity_type = 'node' AND node_users__field_data_field_punch_end.deleted = '0')
WHERE (( (field_data_field_team.field_team_tid IN('0', '10', '11', '22', '12', '2', '21', '3', '13', '4', '14', '5', '15', '6', '16', '7', '17', '18', '20', '19') ) AND (users_roles.rid IN  ('4', '5')) ))
GROUP BY field_data_field_punch_status_field_punch_status_value, users_name, uid_1, field_data_field_punch_start_field_punch_start_value, field_data_field_team_field_team_tid, users_access
ORDER BY field_data_field_punch_start_field_punch_start_value DESC, users_access DESC
4

1 回答 1

3

您在大括号(例如 {field_data_field_team})之间看到的是数据库表的名称。它们显示在大括号之间,因为执行 SQL 查询的代码将大括号之间的内容替换为为数据库表设置的前缀。

假设您的 Drupal 安装使用 drupal7_ 作为前缀;称为 {field_data_field_team} 的表的名称是 drupal7_field_data_field_team。

于 2012-09-29T22:30:58.673 回答