user7295: I'm trying to query the token transactions using the schemas of Cardano-db-sync. When querying ADA transactions, I can easily see the input and output addresses with the values sent by joining the tx, tx_in, and tx_out tables, as shown in the examples here.
However, it is not as easy when I try to query token transactions. I used the multi_asset and ma_tx_out tables to identify which token was sent and in which transaction. I can see the address that received the token, but I cannot identify the address that sent the token when there are multiple input addresses.
For example, how can I know that (addr1q8h ... 8k5s6cnspc) sent the token and not the other input address in this transaction? Is it actually possible to do that by only joining the tables?

user252: 
For example, how can I know that (addr1q8h ... 8k5s6cnspc) sent the token and not the other input address in this transaction? Is it actually possible to do that by only joining the tables?

The multiple inputs of a transaction are not mapped individually to an output. All you can do is query the input UTxO to know assets associated with individual input (which is same for base currency, ADA) - you probably already have the latter part sorted, but just in case - sample example code used by koios for complete transaction information can be found here
In the example you mention, it is easy to deduce since all the assets were present on single address. However, if you try to look at slightly more matured wallet transaction, this will likely complicate further as you'd be associating multiple inputs containing same asset - which is true also for base asset (ADA). The logic would be the same, consider inputs used to consume in desired output, and have the remainder spent to change address.

7295: <p>I'm trying to query the token transactions using the <a href="https://github.com/input-output-hk/cardano-db-sync/blob/master/doc/schema.md" rel="nofollow noreferrer">schemas</a> of Cardano-db-sync. When querying ADA transactions, I can easily see the input and output addresses with the values sent by joining the tx, tx_in, and tx_out tables, as shown in the examples <a href="https://github.com/input-output-hk/cardano-db-sync/blob/master/doc/interesting-queries.md#transaction-outputs-for-specified-transaction-hash" rel="nofollow noreferrer">here</a>.</p>
<p>However, it is not as easy when I try to query token transactions. I used the multi_asset and ma_tx_out tables to identify which token was sent and in which transaction. I can see the address that received the token, but I cannot identify the address that sent the token when there are multiple input addresses.</p>
<p>For example, how can I know that (addr1q8h ... 8k5s6cnspc) sent the token and not the other input address in this <a href="https://cardanoscan.io/transaction/6c6dbbeff048eef367bdc5461ec797d031089ff02d141976a3c718822479d8bc" rel="nofollow noreferrer">transaction</a>? Is it actually possible to do that by only joining the tables?</p>
 252: <blockquote>
<p>For example, how can I know that (addr1q8h ... 8k5s6cnspc) sent the token and not the other input address in this transaction? Is it actually possible to do that by only joining the tables?</p>
</blockquote>
<p>The multiple inputs of a transaction are not mapped individually to an output. All you can do is query the input UTxO to know assets associated with individual input (which is same for base currency, ADA) - you probably already have the latter part sorted, but just in case - sample example code used by <a href="https://api.koios.rest/#post-/tx_info" rel="nofollow noreferrer">koios</a> for complete transaction information can be found <a href="https://github.com/cardano-community/guild-operators/blob/alpha/files/grest/rpc/transactions/tx_info.sql" rel="nofollow noreferrer">here</a></p>
<p>In the example you mention, it is easy to deduce since all the assets were present on single address. However, if you try to look at slightly more matured wallet transaction, this will likely complicate further as you'd be associating multiple inputs containing same asset - which is true also for base asset (ADA). The logic would be the same, consider inputs used to consume in desired output, and have the remainder spent to change address.</p>
