0

帮助我如何从此表中获取用户 ID,例如请愿书 ID = 52,然后如果获取我想要插入到 SYSTEMID 中的第二个表(auto_increment)的所有用户 ID

这是我的命令:

$result = $db->Execute("选择请愿 ID,MT4ACCOUNTID, phpfox_petition_text.petition_goal,user_id " . "来自 phpfox_petition_text,phpfox_tradeusers " . "其中 phpfox_petition_text.petition_goal = $mt4acctid 和 user_id=$systemid ");
        $symbol1 = $result->fields[0];
        $symbol14 = $result->字段[3];

$result212 = $db->Execute("SELECT request_id, user_id " . "from phpfox_petition_sign " . "其中请愿 ID=".$symbol1." and MT4ACCOUNTID=$mt4acctid ORDER BY time_stamp DESC");
  $symbol122 = $result212->字段[1];

  $result111 = $db->Execute("SELECT full_name " . "from phpfox_user " . "where user_id=$systemid ");
        $symbol1user = $result111->fields[0];


        $记录 = 数组();
        $记录[“符号”] = $符号;
        $record["CMD"] = $cmd;
        $record["VOLUME"] = $volume;
        $记录[“价格”] = $价格;
        $record["SLIPPAGE"] = $slippage;
        $record["STOPLOSS"] = $stoploss;
        $record["TAKEPROFIT"] = $takeprofit;
        $record["COMMENT"] = 'MyfaceFx>复制自 ::'.$symbol1user;
        $记录[“魔法”] = $魔法;
        $record["EXPIRATION"] = $expiration;
        $record["MT4SIGNALID"] = $signalid;
        $record["BROKERNAME"] = $brokername;
        $record["MT4ACCTID"] = $mt4acctid;
        $record["TIMESTAMP"] = time();
        $record["SYSTEMID"] =$symbol122;
        $record["ORDERUNITS"] = $basecurrencyunits;
        $record["ACCTBALANCE"] = $acctbalance;
        $record["ACCTCURRENCY"] = $acctcurrency;

    $insertSQL = $db->AutoExecute('phpfox_tradesignals', $record, 'INSERT');
    $insertsignalid = $db->Insert_ID();

它的工作,但只得到1这样的结果:

   过期:systemid       
    ..................................................... ......

              : 27


但我想得到这样的结果:

   过期:systemid       
    ..................................................... ......

              : 27

              : 29

              : 26

              : 34
 ETC....

表请愿

   请愿ID:用户ID        
    ..................................................... ......
    50 : 35   
    52 : 27
    40 : 23  
    52 : 29
    50 : 35   
    52 : 26
    40 : 23  
    52 : 34
   ETC....

表 SYSTEMID

   过期:systemid       
    ..................................................... ......

4

1 回答 1

0

因此,如果您想将一个表中的值插入到另一个表中:

INSERT INTO table2 (systemid)
SELECT user_id
FROM   table1
WHERE  petition_id = 52
于 2013-02-27T11:22:27.607 回答