mysql Selecting from two different tables.

后端 未结 9 778
终归单人心
终归单人心 2021-01-28 05:01
$sql = \"select body, stamp from posts where user_id = \'$userid\' order by stamp desc\";

NOTE: the above query works fine. What I want to do is also s

9条回答
  •  南方客
    南方客 (楼主)
    2021-01-28 06:04

    This should work fine:

    SELECT posts.body, posts.stamp, users.username 
    FROM posts, users 
    WHERE posts.user_id = '$userid' AND posts.user_id = users.user_id
    ORDER BY posts.stamp DESC
    

提交回复
热议问题