# Database,scrpiting my sql

**URL:** <https://forum.inductiveautomation.com/t/database-scrpiting-my-sql/29187>\
**Category:** Ignition\
**Tags:** ignition79, ignition80, scripting, database\
**Created:** [October 18, 2019, 8:46am UTC](https://forum.inductiveautomation.com/t/database-scrpiting-my-sql/29187 "2019-10-18T08:46:39Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![epitigno26](https://avatars.discourse-cdn.com/v4/letter/e/7993a0/32.png) [@epitigno26](https://forum.inductiveautomation.com/u/epitigno26)\
**Post date:** [October 18, 2019, 8:46am UTC](https://forum.inductiveautomation.com/t/database-scrpiting-my-sql/29187/1 "2019-10-18T08:46:39Z")

</div>

CAN I ask for help again?  
i have problems in sql i dont know if it is in sql or scripting, i have my inventory table, the input and the output table, i want to know how i can show the the subtracted value of the input and the output table in my inventory table,thanks

---

<div class="post-metadata">

**Author:** ![jonathan.taylor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jonathan.taylor/32/4048_2.png) [@jonathan.taylor](https://forum.inductiveautomation.com/u/jonathan.taylor)\
**Post date:** [October 18, 2019, 9:45am UTC](https://forum.inductiveautomation.com/t/database-scrpiting-my-sql/29187/2 "2019-10-18T09:45:51Z")

</div>

It’ll likely be your SQL query.

If I’m understanding you correctly, try something like:

```auto
SELECT inventoryTable.*, inputtable.thing - outfeedtable.thing AS SubtractedValue FROM inventoryTable
INNER JOIN outputtable ON outputtable.something_that_is_in_inventoryTable = inventoryTable.something_that_is_in_outputtable
INNER JOIN inputtable ON inputtable.something_that_is_in_inventoryTable = inventoryTable.something_that_is_in_inputtable

```

---

<div class="post-metadata">

**Author:** ![dcamp1](https://avatars.discourse-cdn.com/v4/letter/d/dc4da7/32.png) [@dcamp1](https://forum.inductiveautomation.com/u/dcamp1)\
**Post date:** [October 18, 2019, 10:21am UTC](https://forum.inductiveautomation.com/t/database-scrpiting-my-sql/29187/3 "2019-10-18T10:21:50Z")

</div>

This has been a GREAT companion ! For me. SQL%20in%2010%20Minutes|300x499

---

<div class="post-metadata">

**Author:** ![Sanderd17](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/sanderd17/32/8735_2.png) [@Sanderd17](https://forum.inductiveautomation.com/u/Sanderd17)\
**Post date:** [October 18, 2019, 10:31am UTC](https://forum.inductiveautomation.com/t/database-scrpiting-my-sql/29187/4 "2019-10-18T10:31:42Z")

</div>

When asking such questions, it’s best to give an example: show what data you got (in what tables), and show what data you want to get out.

Then we can help a lot better with constructing the query.
