第一个查询:
SELECT COUNT(*)
FROM `test` t ,`user_test` ut,`user` u
WHERE test_type_id = 1
AND t.created_on >= DATE_SUB(CURDATE(), INTERVAL 1 DAY) AND t.created_on < CURDATE()
AND t.id = ut.test_id
AND u.id = ut.user_id
AND u.user_account_type_id != X
AND u.usr NOT LIKE '%...'
AND u.usr NOT LIKE '%...'
AND u.usr NOT LIKE '%...'
AND u.usr NOT LIKE '%...'
AND u.usr NOT LIKE '%...'
AND u.usr NOT LIKE '%...'
第二个查询:
SELECT COALESCE(SUM(IF(tt.type = 0, 1, 0)), 0) aaa, COALESCE(SUM(IF(tt.type = 1, 1, 0)), 0) bbb
FROM transaction_test tt ,USER u
WHERE tt.created_on >= DATE_SUB(CURDATE(), INTERVAL 10000 DAY) AND tt.created_on < CURDATE()
AND u.id = tt.user_id
AND u.user_account_type_id != X
AND u.usr NOT LIKE '%...'
AND u.usr NOT LIKE '%...'
AND u.usr NOT LIKE '%...'
AND u.usr NOT LIKE '%...'
AND u.usr NOT LIKE '%...'
AND u.usr NOT LIKE '%...'
必须从一个选择中获得结果我试试这个
SELECT COALESCE(SUM(IF(tt.type = 0, 1, 0)), 0) Email, COALESCE(SUM(IF(tt.type = 1, 1, 0)), 0) SMS ,(
SELECT COUNT(*)
FROM `test` t ,`user_test` ut,`user` u
WHERE test_type_id = 1
AND t.created_on >= DATE_SUB(CURDATE(), INTERVAL 1 DAY) AND t.created_on < CURDATE()
AND t.id = ut.test_id
AND u.id = ut.user_id
AND u.user_account_type_id != X
AND u.usr NOT LIKE '%...'
AND u.usr NOT LIKE '%...'
AND u.usr NOT LIKE '%...'
AND u.usr NOT LIKE '%...'
AND u.usr NOT LIKE '%...'
AND u.usr NOT LIKE '%...'
)
FROM transaction_test tt ,USER u
WHERE tt.created_on >= DATE_SUB(CURDATE(), INTERVAL 10000 DAY) AND tt.created_on < CURDATE()
AND u.id = tt.user_id
AND u.user_account_type_id != X
AND u.usr NOT LIKE '%...'
AND u.usr NOT LIKE '%...'
AND u.usr NOT LIKE '%...'
AND u.usr NOT LIKE '%...'
AND u.usr NOT LIKE '%...'
AND u.usr NOT LIKE '%...'
我不满意使用两次
AND u.user_account_type_id != X
AND u.usr NOT LIKE '%...'
AND u.usr NOT LIKE '%...'
AND u.usr NOT LIKE '%...'
AND u.usr NOT LIKE '%...'
AND u.usr NOT LIKE '%...'
AND u.usr NOT LIKE '%...'
这部分任何机构都可以建议如何避免这种情况?提前致谢