Closed. This question needs details or clarity。它当前不接受答案。
                            
                        
                    
                
                            
                                
                
                        
                            
                        
                    
                        
                            想改善这个问题吗?添加详细信息并通过editing this post阐明问题。
                        
                        4年前关闭。
                                                                                            
                
        
第一个查询:

  SELECT artikkel_id, liige_id, summa, date, SUM(summa) as papp
    FROM rent WHERE date < NOW() group by liige_id


结果:
php - 加入/合并两个查询-LMLPHP
第二个查询:

SELECT artikkel_id, maksja_id, summa, timestamp, SUM(summa) as peaks
    FROM tulu group by maksja_id


结果:php - 加入/合并两个查询-LMLPHP

在表maksja_id和liige_id中是相同的。

“ join”的要点是,我可以比较和显示liige_id / maksja_id的“ papp”和“ peaks”值,并在表行中用颜色标记,当papp

最佳答案

您想对结果集都说join

select xx.artikkel_id, l.nimi, xx.summa, xx.`date`, xx.papp,
yy.summa as yysumma, yy.`timestamp`, yy.peaks
from (SELECT artikkel_id, liige_id, summa, date, SUM(summa) as papp
        FROM rent WHERE date < NOW() group by liige_id) xx
join (SELECT artikkel_id, maksja_id, summa, timestamp,
 SUM(summa) as peaks FROM tulu group by maksja_id) yy
 on xx.liige_id = yy.maksja_id
join liige l on l.liige_id = xx.liige_id;

关于php - 加入/合并两个查询,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/34582732/

10-12 13:22