【问题标题】:Multiple INSERT query's fetching last_insert_id of each each多个 INSERT 查询获取每个的 last_insert_id
【发布时间】:2015-07-01 04:06:10
【问题描述】:
mysql_query( "INSERT INTO users(email, password) VALUES ('$email','$password')" );
$user_id = mysql_insert_id( );

mysql_query( "INSERT INTO business_details ( business_id, name, address, city, state, country, pincode) VALUES ('$category','$business_name', '$business_address', '$city', '$state', '$country', '$pincode')" );
$idB = mysql_insert_id( );

mysql_query( "INSERT INTO user_profiles (name, phone, user_id, business_details_id) VALUES ('$person_name', '$phone_number', '$user_id', '$idB')" );

将所有查询插入到一个中的最佳方法是什么?有可能吗?

【问题讨论】:

标签: php mysql


【解决方案1】:

不,MySQL 不支持 - 只有 Oracle 可以做到。

【讨论】:

    【解决方案2】:

    MySQL 不支持在单个 INSERT 语句中插入多表

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-10-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-04-29
      • 2011-12-26
      • 2018-12-13
      • 1970-01-01
      相关资源
      最近更新 更多