2015-11-16 31 views
-1

我正在使用mysql來生成正確的輸出。我用左連接兩個表,我下面的兩個表結構給出的where子句聯接:如何使用mysql查詢獲取正確的輸出?

我使用的查詢

select e.fee_particular,e.fee_amount,s.paid from es_feemaster e left join es_feepaid_new s on s.fee_particular=e.es_feemasterid where s.es_preadmissionid=914 and s.voucherid=208 and e.fee_class=13 

我的第一個表結構

enter image description here

我的第二個表格結構是

enter image description here

enter image description here

我得到這樣的輸出

enter image description here

,但我的願望輸出應儘快

enter image description here

請幫我產生慾望輸出可能。

在此先感謝

回答

0

外連接的是解決方案,我希望。 NVL也可以做同樣的事情。

select e.fee_particular,e.fee_amount,s.paid from es_feemaster e left join es_feepaid_new s on s.fee_particular=NVL(e.es_feemasterid,s.fee_particular) where s.es_preadmissionid=914 and s.voucherid=208 and e.fee_class=13 
+0

您的查詢不起作用顯示錯誤功能acadtouch.NVL不存在 –

+0

NVL是oracle驗證的空值驗證。可能是一個MySQL替換會修復它的朋友。 –

+0

是的,mysql有ifnull()函數,但輸出不正確,需要我 –