我在mysql中有3个表
table 1
date name total recieve
2013-05-09 "aa" 20 15
2013-05-09 "bb" 10 17
table 2
name tree
"bb" "a1"
"aa" "a2"
table 3
date tree users
2013-05-09 "a1SI" 19
2013-05-09 "a1NO" 24
2013-05-09 "a2SI" 39
2013-05-09 "a2NO" 22
我需要一个带有树表的视图
这是我需要的观点:
date name tree total recieve userSI userNO
2013-05-09 "aa" "a2" 20 15 39 22
2013-05-09 "bb" "a1" 10 17 19 24
我有一半的查询
SELECT t1.`date` , t1.`name` , t2.`tree` , t1.`total` , t1.`recieve`,
FROM `table1` t1
INNER JOIN `table2` t2 ON t1.`name` = t2.`name`
ORDER BY `t1`.`date` DESC
但我不知道三个表的视图如何,其他问题是树的记录,因为我有树“a1”和“a1Si”和“a2NO”,并且在视图中我需要关联 3 列