首页 > 解决方案 > MYSQLdump 不能在 where 子句中使用 SELECT 语句

问题描述

我环顾四周,据我所知这应该可以正常工作我尝试使用我的 sql 转储来获取一堆注释注释,我让它与诸如 --no-data 之类的语句以及 WHERE 的其他变体一起使用,但是不是这个我一直在用 PHP 做的

mysqldump --user=root --host=localhost DB notes_comments --where="notes_comments.note_id IN (SELECT notes.note_id FROM notes WHERE notes_category_id=1 OR notes.datetime_created > '2018-04-30 18:16:15')" > db.sql

上面的语句是我想要使用但结果中没有记录的语句,db.sql 文件有它删除表(如果存在)然后创建它但其中没有记录

但是,如果我使用: mysqldump --user=root --host=localhost DB notes_comments --where="notes_comments.note_id IN (1,2,3,4,5)" > db.sql 它可以工作并在 db.sql 中提供插入语句

我已经在原始 WHERE 中测试了 SELECT 并在 WHERE 中对其进行了测试,以获得我想要的记录并且它工作正常。

我不确定问题是什么

用额外的语句编辑:

mysqldump --user=root --host=localhost DB notes_comments --where="notes_comments.note_id IN (SELECT notes.note_id FROM notes)" > db.sql

再次不返回记录但创建结构

mysqldump --user=root --host=localhost DB notes_comments --where="notes_comments.note_id IN (SELECT notes.note_id FROM notes WHERE notes_category_id=1 )" > db.sql

也不返回任何记录但创建结构

mysqldump --user=root --host=localhost DB notes_comments --where="notes_comments.note_id IN (SELECT notes.note_id FROM notes WHERE notes.datetime_created > '2018-05-01 10:20:29')" > db.sql

像其他人一样不返回任何记录但创建结构

标签: phpmysql

解决方案


推荐阅读