问题描述
我有两个表(1)tblborrowloan包含列pno,LoanAmt。
(2)tblextraloan包含列pno,LoanAmt。
我需要从表中选择LoanAmt 2根据pno但是如果它返回null则数据应该来自表1,基于相同的pno。
这里是我的qury ..但没有执行,使用Mysql(Ver 5.0)作为后端。
帮助我。在此先感谢。
ifnull(SELECT LoanAmt FROM tblextraloan其中pno ='0706'为L)然后(SELECT LoanAmt FROM tblborrowloan其中pno ='0706'为L) ;
I have two tables (1) tblborrowloan contain columns pno, LoanAmt.
(2) tblextraloan contain columns pno, LoanAmt.
I need to select LoanAmt from table 2 according to pno but if it returns null then data should come from table 1 on the basis of same pno.
here is my qury.. but not executing, using Mysql(Ver 5.0) as backend.
Help me out. Thanks in Advance.
ifnull (SELECT LoanAmt FROM tblextraloan where pno = '0706' as L) then (SELECT LoanAmt FROM tblborrowloan where pno = '0706' as L);
推荐答案
ifnull((SELECT LoanAmt FROM tblextraloan where pno = '0706' as L),(SELECT LoanAmt FROM tblborrowloan where pno = '0706' as L));
了解更多详情请参阅以下链接。
[]
这篇关于如何在MYSQl查询中使用条件if-else。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!