我想创建一个列出所有用户及其个人资料信息的查询,但是必须使用相当复杂的程序获取个人资料信息。
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的条目,该entity_id引用了配置文件表,还有一个引用修订号的修订ID。我总是需要最高的最新版本