我有一个包含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%';
答案 0 :(得分:1)
一种方法是将“查询标识符”作为结果集输出的第一列,例如序列号作为“键”。
SELECT 1 as q, t.* FROM foo t WHERE ... ;
SELECT 2 AS q, t.* FROM foo2 t WHERE ... ;
(有关如何在每个生成的语句中包含此唯一值的示例,请参阅我对上一个问题的答案的更新。)
答案 1 :(得分:0)
你可以做这样的事情,它只返回有行的查询:
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以编程方式生成上述查询。