我想创建一个查询来列出所有用户及其个人资料信息,但是必须使用相当复杂的过程来获取个人资料信息。
SELECT options.`value` FROM users
RIGHT JOIN profile on(profile.uid = users.uid)
RIGHT JOIN field_data_field_ethnicity on(field_data_field_ethnicity.entity_id = profile.pid)
RIGHT JOIN options on(field_data_field_city.field_ethnicity_value = bdc_options.`index` AND bdc_options.`key` = "ethnicity")
WHERE users.uid = 1 #needs to go through all users in table
ORDER BY field_data_field_ethnicity.revision_id DESC
LIMIT 1
SELECT options.`value` FROM users
RIGHT JOIN profile on(profile.uid = users.uid)
RIGHT JOIN field_data_field_city on(field_data_field_city.entity_id = profile.pid)
RIGHT JOIN options on(field_data_field_city.field_city_value = bdc_options.`index` AND bdc_options.`key` = "city")
WHERE users.uid = 1
ORDER BY field_data_field_ethnicity.revision_id DESC
LIMIT 1
只是从这两个领域,我将如何通过用户表并得到类似
USER | CITY | ETHNICITY
1 | London | Koalabear
2 | Paris | Fiddle
以下是有问题的表格:http: //pastebin.com/feNvzMZw
字段表包含所有条目,其中 entity_id 引用配置文件表,修订 id 引用修订号。我总是需要最高的更新