两张表联合查询

//art表中有一个字段是作者id,
//根据文章id在art表中找到作者id,根据作者id在admin_user找到作者头像,姓名合并输出
//art是表1;admin_user是表2,
$artId = 2;
$sql = "SELECT `user_id`,`dest`,`name`,headUrl FROM  art INNER JOIN admin_user ON art.user_id = admin_user.uid
          WHERE `id` = '$artId'";
$newSql = new Mysql();

$rtn = $newSql->selectTable($sql,true);

 

你可能感兴趣的:(数据库)