首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >mysql,如何批量执行许多查询并知道哪些查询正在返回行

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

Stack Overflow用户
提问于 2012-09-01 06:33:45
回答 2查看 410关注 0票数 2

我有一个有800个查询的脚本。它们中的大多数不返回任何内容。

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

代码语言:javascript
复制
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%';
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2012-09-01 06:41:16

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

代码语言:javascript
复制
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以编程方式生成上述查询。

票数 0
EN

Stack Overflow用户

发布于 2012-09-01 06:50:19

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

代码语言:javascript
复制
SELECT 1 as q, t.* FROM foo t WHERE ... ;
SELECT 2 AS q, t.* FROM foo2 t WHERE ... ;

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

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/12223245

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档