Perform airthmatic operation in select sql query when airthmatic operator stored in database


idaboperationc
123+5
223+6
332/1
447*28
5542-27
630/0
Using operation in fetching the value


select  case 
                   when operation='+' then a+b
                   when operation='-' then a-b 
                   when operation='*' then a*b
                   when operation='/' then a/b
           END 
from table ;

Using in where  condition while checking the value with c if airthmatic operation is equal to the the value in c coloum


   select * from expressions where c= case when operation='+' then a+b
                                    when operation='-' then a-b 
when operation='*' then a*b
when operation='/' then a/b
END 

Comments

Popular posts from this blog

Enable the imap in support in xampp server