<p>You are probably looking for this:
<a href="https://github.com/input-output-hk/cardano-db-sync/blob/master/doc/interesting-queries.md#transaction-inputs-for-specified-transaction-hash" rel="nofollow noreferrer">https://github.com/input-output-hk/cardano-db-sync/blob/master/doc/interesting-queries.md#transaction-inputs-for-specified-transaction-hash</a></p>

CC BY-SA 4.0
2023-10-11T09:29:17.750Z
Yeah, Thank you. The query works fine.
manhdt
CC BY-SA 4.0
2023-10-11T17:08:55.830Z
I'm glad to hear it.
George - APEX Stake Pool
CC BY-SA 4.0
2023-10-11T06:33:14.193Z
2023-10-11T06:33:14.193Z
George - APEX Stake Pool
<p>Could anyone help to query input UTXOs of a transaction, please?</p>
<p>I tried to use tx_in and tx_out tables to view the detail inputs and outputs of the transaction <a href="https://cardanoscan.io/transaction/81a53921f59028c56eb7920d944d1db5997f27fbae249fa520413990c4a7d944?tab=utxo" rel="nofollow noreferrer">https://cardanoscan.io/transaction/81a53921f59028c56eb7920d944d1db5997f27fbae249fa520413990c4a7d944?tab=utxo</a></p>
<p>First of all, I could get the outputs of the transaction easily by using the following query</p>
<p><a href="https://i.sstatic.net/LLA3W.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/LLA3W.png" alt="enter image description here" /></a></p>
<p><a href="https://i.sstatic.net/7I35g.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/7I35g.png" alt="enter image description here" /></a></p>
<p>However, when trying to get Input UTXOs using SQL queries, there was an issue I would like to describe as the following.</p>
<ol>
<li>I've tried to query data from tx_in table to get tx_in_id that is used for the transaction</li>
</ol>
<pre><code>select * from tx_in where tx_out_id = 76360126; -&gt; There are 2 tx_id 76360263 and 76363286
</code></pre>
<p><a href="https://i.sstatic.net/g1yqE.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/g1yqE.png" alt="enter image description here" /></a>
2. Then I tried to query back to the table tx_out with 2 above tx_id. However, it shows more addresses than those on Cardanoscan; some are not actually used in the transaction. How Could I get the exact Input UTXOs of a transaction?</p>
<p><a href="https://i.sstatic.net/V21Vc.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/V21Vc.png" alt="enter image description here" /></a></p>
<p><a href="https://i.sstatic.net/uwBie.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/uwBie.png" alt="enter image description here" /></a></p>

<cardano-db-sync>
How to query input UTXOs of a transaction
# How to query input UTXOs of a transaction

(Asked by: username_0 on 2023-10-11)

Could anyone help to query input UTXOs of a transaction, please?
I tried to use tx_in and tx_out tables to view the detail inputs and outputs of the transaction https://cardanoscan.io/transaction/81a53921f59028c56eb7920d944d1db5997f27fbae249fa520413990c4a7d944?tab=utxo
First of all, I could get the outputs of the transaction easily by using the following query


However, when trying to get Input UTXOs using SQL queries, there was an issue I would like to describe as the following.

I've tried to query data from tx_in table to get tx_in_id that is used for the transaction

select * from tx_in where tx_out_id = 76360126; -> There are 2 tx_id 76360263 and 76363286


2. Then I tried to query back to the table tx_out with 2 above tx_id. However, it shows more addresses than those on Cardanoscan; some are not actually used in the transaction. How Could I get the exact Input UTXOs of a transaction?

**Tags:** cardano-db-sync

---

## 1 answers

### Answer by username_1 on 2023-10-11. Score: 1 | Accepted answer

You are probably looking for this:
<https://github.com/input-output-hk/cardano-db-sync/blob/master/doc/interesting-queries.md#transaction-inputs-for-specified-transaction-hash>

> **Comments:**
> **username_0**: Yeah, Thank you. The query works fine.  
> **username_1**: I'm glad to hear it.  

---

