Note that there are some explanatory texts on larger screens.

plurals
  1. POMySQL if condition null
    primarykey
    data
    text
    <p>I am having database columns</p> <hr> <p>table name:</p> <ul> <li>sales</li> <li>trans_details</li> </ul> <p>Initially data will be inserted into <strong>sales</strong> lateron when quantity dispatched <strong>trans_details</strong> table get updated</p> <hr> <p>columns in sales </p> <ul> <li>total_quantity</li> <li>e.t.c</li> </ul> <p>columns in trans_details</p> <ul> <li>ordered_quantity</li> <li>dispatched_quantity</li> <li>pending_quantity</li> <li>e.t.c</li> </ul> <hr> <p>i want to display all the values: - ordered_quantity - dispatched_quantity - pending_quantity</p> <pre><code>SELECT IF(trans.ordered_quantity!='',trans.ordered_quantity,(sorder.total_quantity)) AS quantity, IF(trans.dispatched!='',trans.dispatched,0) AS today_dispatched_qty, IF(trans.dispatched!='',trans.dispatched,0) AS dis_qty, IF(trans.Pending_quantity!='',trans.Pending_quantity,sorder.total_quantity) AS pending_qty FROM sales as sorder LEFT OUTER JOIN trans_details as trans </code></pre> <hr> <p>the query is working fine but when the quantity fully dispatched it should '0' but right now it is showing total_quantity... and when i replace <code>sorder.total_quantity</code> with '0' in this condition <code>IF(trans.Pending_quantity='0',trans.Pending_quantity,sorder.total_quantity) AS pending_qty</code>... initially it is showing '0' but it should show the total_quantity...</p> <hr> <h2>sample output:</h2> <p>total_quantity..........dispatched_quantity.......pending_quantity</p> <pre><code>50 45 5 5 5 0 5 0 5 </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload