$askforuser=$db->query("SELECT u.*,ud.* FROM users u INNER JOIN user_detail ud ON ud.userid=u.id");
$askforuser1 = $askforuser->fetchAll(PDO::FETCH_ASSOC);
用户和user_details表具有&created; created_at'列。
当我这样的时候:
foreach ($askforuser1 as $udet) {
extract($udet);
echo $created_at;
}
我在屏幕上看不到任何内容但是如果我
foreach ($askforuser1 as $udet) {
extract($udet);
echo $userid; // user_detail table output.
echo $id; // users table output;
}
那么,我怎样才能得到用户' created_at或user_detail创建了__?
谢谢
答案 0 :(得分:0)
编辑Sql查询
SELECT u.*,ud.*, u.created_at as `user_created_at`, ud.created_at as `user_details_created_at` FROM users u INNER JOIN user_detail ud ON ud.userid=u.id
然后在提取后以PHP格式获取它
$user_created_at // user table
$user_details_created_at // user_details table