mysql Selecting from two different tables.

后端 未结 9 791
终归单人心
终归单人心 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 05:42

    $sql = "
    select body, stamp from posts where user_id = '$userid' order by stamp desc
    UNION ALL
    select body, stamp from username where user_id = '$userid' order by stamp desc
    ";
    

    http://dev.mysql.com/doc/refman/5.0/en/union.html

提交回复
热议问题