Ответов: 3 Просмотров: 2061
![](templates/InvisionExBB/im/spacer.gif) |
Мелкий пишет:CODE ( SQL):
скопировать код в буфер обмена
SELECT id FROM ( SELECT id, some_number FROM tbl1 WHERE date BETWEEN ? AND ? UNION ALL SELECT id, some_number FROM tbl2 WHERE date BETWEEN ? AND ? UNION ALL SELECT id, some_number FROM tbl3 WHERE date BETWEEN ? AND ? UNION ALL SELECT id, some_number FROM tbl4 WHERE date BETWEEN ? AND ? ) d GROUP BY id HAVING sum(some_number) = ?
Спасибо! Идею понял, но есть еще вопрос, названия полей и их количество должны быть одинаковы во всех четырех таблицах?
я получил ответ на свой запрос - #1248 - Every derived table must have its own alias
Каждый подзапрос должен иметь уникальный псевдоним?
CODE ( SQL):
скопировать код в буфер обмена
SELECT tnum FROM ( SELECT tnum, sum(hp10_gamma) AS summa FROM dose_rados WHERE date_change BETWEEN '2018-01-01' AND '2018-09-30' UNION ALL SELECT tnum, sum(dose) AS summa FROM doz_tld WHERE date BETWEEN '2018-01-01' AND '2018-09-30' UNION ALL SELECT tnum, sum(dose) AS summa FROM internal WHERE meash_date BETWEEN '2018-01-01' AND '2018-09-30' UNION ALL SELECT tnum, sum(dose) AS summa FROM neutron_dose WHERE date '2018-01-01' AND '2018-09-30' ) GROUP BY tnum HAVING sum(summa) >='6' #1248 - Every derived table must have its own alias
|