dtjpz48440 2015-10-21 06:55
浏览 94
已采纳

对last_insert_id使用where子句

I need to fetch row of last inserted id.If the last row value of id is 1234.Then I have to use that value in where clause.I am trying following code.but not working

$stmt8->prepare( "SELECT stat_id FROM " ."raw_nw_static_db_icube"."WHERE id=LAST_INSERT_ID ");
  $stmt8->execute();
$stmt8->bind_result($stat_id);  
$stmt8->fetch();
echo $stat_id;

Do anyone have idea to do this ?

  • 写回答

3条回答 默认 最新

  • douguang9014 2015-10-21 06:58
    关注

    Try this :-

    $stmt8->prepare( "SELECT stat_id FROM raw_nw_static_db_icube WHERE id=LAST_INSERT_ID ");
    

    For get last id use order by desc desc

    SELECT stat_id FROM raw_nw_static_db_icube order by id desc
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?