doumuyu0837 2015-02-18 09:41
浏览 14

连接2个查询并发送到mysql_query

Now I have one table and copy this table into another table and this work... But now I have one new array in new table and I need to save now date... How to connect this 2 queries into one..

$sql = "INSERT INTO $tbl_name2(name, money) SELECT name, money FROM $tbl_name WHERE id='$idd'";
$sql ="INSERT INTO $tbl_name2(time)VALUES('$time')";
$result = mysql_query($sql);
  • 写回答

2条回答 默认 最新

  • dongnai1876 2015-02-18 09:43
    关注

    Simply add the parameter to your first query.

    $sql = "INSERT INTO $tbl_name2(name, moneytime) SELECT name, money,$time FROM $tbl_name WHERE id='$idd'";
    

    But you shouldn't use the mysql_* API because these is depricated. And also you should use prepared statement. TThese are much more safty and readable.

    评论

报告相同问题?

悬赏问题

  • ¥15 pyqt5tools安装失败
  • ¥15 mmdetection
  • ¥15 nginx代理报502的错误
  • ¥100 当AWR1843发送完设置的固定帧后,如何使其再发送第一次的帧
  • ¥15 图示五个参数的模型校正是用什么方法做出来的。如何建立其他模型
  • ¥100 描述一下元器件的基本功能,pcba板的基本原理
  • ¥15 STM32无法向设备写入固件
  • ¥15 使用ESP8266连接阿里云出现问题
  • ¥15 BP神经网络控制倒立摆
  • ¥20 要这个数学建模编程的代码 并且能完整允许出来结果 完整的过程和数据的结果