运行查询时出现这种情况:
ACCOUNT
-----------
account_id account_name
1 STARCLASS
2 STEPWAY
COMPANY
-----------
company_id company_account_id company_name
1 1 STORE 01
2 2 STORE 01
3 2 STORE 02
RESUME
-----------
resume_id resume_company_id resume_start_date resume_end_date resume_total
1 1 2017-01-01 2017-01-31 300.00
2 2 2017-01-01 2017-01-31 147.00
3 3 2017-01-01 2017-01-31 50.00
QUERY
-----------
SELECT *
FROM resume
LEFT JOIN company ON company_id = resume_company_id
LEFT JOIN account ON account_id = company_account_id
GROUP BY account_id
WHILE
-----------
while ($i < $num) {
.......
$account_name = mysql_result($result,$i,"account_name");
$company_name = mysql_result($result,$i,"company_name");
.......
QUERY RESULTS
-----------
ID company_name account_name resume_start_date resume_end_date resume_total
1 STORE 01 STARCLASS 2017-01-01 2017-01-31 300.00
2 STORE 01 STEPWAY 2017-01-01 2017-01-31 147.00
3 **NOT SHOW COMPANY NAME** 2017-01-01 2017-01-31 50.00
**AND ACCOUNT NAME**
当我按ACCOUNT_ID分组时,最后一行变量liks account_name和company_name显示为空白。
有办法解决? 关于这个的任何提示?
感谢所有人的帮助
答案 0 :(得分:0)
应包含未通过聚合函数传递的表达式。同样,我不确定您使用的软件包版本,但我的结果只包含两行。
无论
resume_total
).... GROUP BY account_id
)。SELECT * FROM resume
仍在实现(3条记录但只有两条记录的值为LEFT JOIN值。)。如果您希望列表按顺序使用ORDER BY,或者使用选定表达式或聚合函数的GROUP BY。