Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/csharp-4.0/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
mysql,如何批量执行许多查询,并知道哪些查询返回行_Mysql - Fatal编程技术网

mysql,如何批量执行许多查询,并知道哪些查询返回行

mysql,如何批量执行许多查询,并知道哪些查询返回行,mysql,Mysql,我有一个包含800个查询的脚本。他们中的大多数人一无所获 如何修改此脚本以了解哪些脚本仅返回行 SELECT * FROM `theprint_depotlive-v16`.`xmlconnect_notification_template` WHERE `name` LIKE '%1720%'; SELECT * FROM `theprint_depotlive-v16`.`xmlconnect_notification_template` WHERE `push_title` LIKE '%

我有一个包含800个查询的脚本。他们中的大多数人一无所获

如何修改此脚本以了解哪些脚本仅返回行

SELECT * FROM `theprint_depotlive-v16`.`xmlconnect_notification_template` WHERE `name` LIKE '%1720%';
SELECT * FROM `theprint_depotlive-v16`.`xmlconnect_notification_template` WHERE `push_title` LIKE '%1720%';
SELECT * FROM `theprint_depotlive-v16`.`xmlconnect_notification_template` WHERE `message_title` LIKE '%1720%';
SELECT * FROM `theprint_depotlive-v16`.`xmlconnect_queue` WHERE `push_title` LIKE '%1720%';
SELECT * FROM `theprint_depotlive-v16`.`xmlconnect_queue` WHERE `message_title` LIKE '%1720%';
SELECT * FROM `theprint_depotlive-v16`.`xmlconnect_queue` WHERE `type` LIKE '%1720%';
SELECT * FROM `theprint_depotlive-v16`.`zizio_groupsale` WHERE `zizio_object_id` LIKE '%1720%';
SELECT * FROM `theprint_depotlive-v16`.`zizio_groupsale` WHERE `name` LIKE '%1720%';
SELECT * FROM `theprint_depotlive-v16`.`zizio_groupsale` WHERE `recurrence_child` LIKE '%1720%';
SELECT * FROM `theprint_depotlive-v16`.`zizio_groupsale` WHERE `recurrence_ancestor` LIKE '%1720%';

您可以这样做,只返回包含行的查询:

SELECT
  '`theprint_depotlive-v16`.`xmlconnect_notification_template`' as table,
  '`name` LIKE \'%1720%\'' as condition,
  count(*) as count
FROM `theprint_depotlive-v16`.`xmlconnect_notification_template`
WHERE `name` LIKE '%1720%'

UNION

SELECT
  '`theprint_depotlive-v16`.`xmlconnect_notification_template`' as table,
  '`push_title` LIKE \'%1720%\'' as condition,
  count(*) as count
FROM `theprint_depotlive-v16`.`xmlconnect_notification_template`
WHERE `push_title` LIKE '%1720%'

UNION

...

WHERE count > 0;

如果查询列表位于表或mysql可以读取的内容中,则可以使用动态SQL以编程方式生成上述查询。

一种方法是将“查询标识符”作为结果集输出的第一列,例如将序列号作为“键”


(有关如何在每个生成的语句中包含此唯一值的示例,请参阅我对上一个问题的回答的更新。)

哎哟,这太难了。我的脚本有800条语句,是否还有更通用的方法?现在如何运行它,以及您得到了什么样的输出?只是一个巨大的文本文件中一个接一个的一组表结果,或者你不知道哪个结果集链接回哪个原始查询?例如,你能把类似于
print1
打印2,等等(可以使用正则表达式或简单的批处理脚本自动完成)?
SELECT 1 as q, t.* FROM foo t WHERE ... ;
SELECT 2 AS q, t.* FROM foo2 t WHERE ... ;