gpt4 book ai didi

php - 从两个表中插入不匹配的记录

转载 作者:行者123 更新时间:2023-11-29 22:12:29 25 4
gpt4 key购买 nike

我目前发现自己很困惑,因为这个查询在 MySQL 中运行良好,但在 PHP 中运行得不太好。返回消息指出“操作数应包含 1 列”。提前谢谢您

表1

|交易日期 |打开 |     |高     |低       |关闭     |音量 |

+------------+------------+------------+--------- --+------------+---------+

| 2015-07-16 | 60.779999 | 60.869999 | 60.75 | 60.75 60.830002 | 1050400 |

| 2015-07-15 | 60.34 | 60.34 60.560001 | 60.560001 60.220001 | 60.220001 60.389999 | 1096400 |

| 2015-07-14 | 60.18     | 60.610001 | 60.610001 60.169998 | 60.549999 | 60.549999 1328900 |

| 2015-07-13 | 60.00     | 60.23 | 60.23 60.00     | 60.18     | 973300 |

| 2015-07-10 | 59.57     | 59.82 | 59.82 59.380001 | 59.720001 | 1506700 |

表2+------------+------------+------------+------------+ -----------+---------+

|交易日期 |打开 |     |高     |低       |关闭     |音量 |

+------------+------------+------------+--------- --+------------+---------+

| 2015-07-17 | 60.950001 | 60.950001 60.950001 | 60.950001 60.66 | 60.66 60.790001 | 731000 |

| 2015-07-16 | 60.779999 | 60.869999 | 60.75 | 60.75 60.830002 | 1050400 |

| 2015-07-15 | 60.34 | 60.34 60.560001 | 60.560001 60.220001 | 60.220001 60.389999 | 1096400 |

| 2015-07-14 | 60.18     | 60.610001 | 60.610001 60.169998 | 60.549999 | 60.549999 1328900 |

| 2015-07-13 | 60.00     | 60.23 | 60.23 60.00     | 60.18     | 973300

这是查询

    $insertline  = " INSERT INTO `$table1` (SYMBOL, Trade_Date, Open, High, Low, Close, Volume, Adj_Close) SELECT SYMBOL, Trade_Date, Open, High, Low, Close, Volume, Adj_Close FROM `$table2` WHERE TRADE_DATE NOT IN (SELECT * FROM `$table2`) "; 

$result6   = mysqli_query($dbcon, $insertline) or die(mysqli_error($dbcon));

最佳答案

(A) 您不能执​​行not in(选择[多列])(B) 您不在 需要查看table1,而不是table2,因为您正在尝试合并table2 中涵盖尚未在table1 中的日期的数据。

关于php - 从两个表中插入不匹配的记录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31500843/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com