Click here to Skip to main content
15,881,248 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
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);
Posted
Updated 23-Sep-13 2:03am
v2

1 solution

I think the query syntax you have written is not correct as per the MYSQL syntax.


If the first expression is not null it returns the first expression result,else the second one.

the query could be..
SQL
ifnull((SELECT LoanAmt FROM tblextraloan where pno = '0706' as L),(SELECT LoanAmt FROM tblborrowloan where pno = '0706' as L));


for more details refer this below link.
http://dev.mysql.com/doc/refman/5.0/en/control-flow-functions.html#function_ifnull[^]
 
Share this answer
 
v2
Comments
Member 12651508 31-Aug-16 4:59am    
hello There I used if condition to filter data accurately but its not work.
I am trying to filter my product like Brand, Price and Fabric.
Its Filter data individual i.e if you Click brand Then its show only Brand.
But we need deep filter

Please help me out Thanks In Advance
23) {
$trimstring = substr($string, 0, 23);
} else {
$trimstring = $string;
}
?>

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900