原始查询是
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
仅打印网址
我需要的是将该网址添加到第一个查询
答案 0 :(得分: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