## 怎么从用户的多条数据取其一条

oepre_weibo.content, 表二的信息

`select oepre_user.username,oepre_weibo.content,oepre_user_photo.uploadfiles from oepre_user oepre_user left join oepre_weibo oepre_weibo on oepre_weibo.userid = oepre_user.userid left join oepre_user_photo oepre_user_photo on oepre_user_photo.userid =oepre_user.userid limit \$page \$pagesize`

0

0

#### 引用来自“青春陪葬了无知的年华”的答案

+1
0

0
```sql= "SELECT MAX(p.id),ucon.username,ucon.content,p.uploadfiles" +
" FROM oepre_user_photo p," +
" (SELECT u.username,u.userid,uw.content, MAX(uw.id) max_uwid" +
" FROM oepre_weibo uw INNER JOIN oepre_user u ON" +
" u.userid = uw.userid and uw.content IS NOT NULL" +
" GROUP BY uw.userid) ucon" +
" WHERE p.userid = ucon.userid " +
" GROUP BY p.userid LIMIT ?";```

0

#### 引用来自“青春陪葬了无知的年华”的答案

```sql= "SELECT MAX(p.id),ucon.username,ucon.content,p.uploadfiles" +
" FROM oepre_user_photo p," +
" (SELECT u.username,u.userid,uw.content, MAX(uw.id) max_uwid" +
" FROM oepre_weibo uw INNER JOIN oepre_user u ON" +
" u.userid = uw.userid and uw.content IS NOT NULL" +
" GROUP BY uw.userid) ucon" +
" WHERE p.userid = ucon.userid " +
" GROUP BY p.userid LIMIT ?";```

`select distinct oepre_user_photo.userid, oepre_user.username,oepre_user_profile.monolog,oepre_user_photo.uploadfiles from oepre_user oepre_user left join oepre_user_profile oepre_user_profile on oepre_user_profile.userid = oepre_user.userid left join oepre_user_photo oepre_user_photo on oepre_user_photo.userid =oepre_user.userid group by oepre_user_photo.userid ORDER BY oepre_user_photo.timeline DESC limit \$page \$pagesize`