0

原始查询是

SELECT user_id, user_location, displayname FROM engine4_users WHERE user_location IS NOT NULL

打印 user_id、user_location 和 displayname,

Ex:
1 30,32 demo
2 30,31 demo
3 33,32 demo

但现在我需要从另一张桌子上获取用户图片,我有这个,

SELECT  s.storage_path as url FROM engine4_storage_files as s
LEFT JOIN  engine4_users as u ON s.file_id = u.photo_id

仅打印 URL

我需要的是将该网址添加到第一个查询

4

1 回答 1

2

尝试这个:

SELECT u.user_id, u.user_location, u.displayname, s.storage_path as url 
FROM engine4_users u 
LEFT JOIN engine4_storage_files s
ON s.file_id = u.photo_id 
WHERE u.user_location IS NOT NULL

应要求在评论中扩展:

SELECT u.user_id, u.user_location, u.displayname, w.value as about, s.storage_path as url 
FROM engine4_users u 
LEFT JOIN engine4_user_fields_values w 
ON w.item_id = u.user_id
LEFT JOIN engine4_storage_files s
ON s.file_id = u.photo_id 
WHERE u.user_location IS NOT NULL
于 2015-04-14T03:44:07.970 回答