如何从多个表中获取7天的数据

时间:2016-05-16 09:38:04

标签: mysql select

从mysql中的多个表中获取7天的数据。

这是我的选择陈述:

$sql="SELECT * FROM chain_management UNION 
SELECT * FROM adagio_accounting_suite UNION
SELECT * FROM billquick UNION 
SELECT * FROM budgetingdb UNION 
SELECT * FROM chain_management UNION
SELECT * FROM accountpayable
WHERE DATE >= DATE_SUB(CURDATE(), INTERVAL 7 DAY) ORDER BY curtime DESC";

1 个答案:

答案 0 :(得分:0)

你可以尝试使用它:

$sql="SELECT * FROM (SELECT * FROM chain_management UNION 
SELECT * FROM adagio_accounting_suite UNION
SELECT * FROM billquick UNION 
SELECT * FROM budgetingdb UNION 
SELECT * FROM chain_management UNION
SELECT * FROM accountpayable) as XYZ
WHERE DATE >= DATE_SUB(CURDATE(), INTERVAL 7 DAY) ORDER BY curtime DESC";