BigQuery/ Ethereum dataset - how to write the code

折月煮酒 提交于 2019-12-02 06:01:13

You just simply took the address that exists only in one table and not in another - thus JOIN excludes it from result

You can use LEFT JOIN instead of JOIN in case if address of your interest is in one (first) table but not in another (second)

As in below example

#standardSQL
SELECT
  from_address,
  to_address,
  value,
  transaction_hash
FROM
  `bigquery-public-data.ethereum_blockchain.token_transfers` AS token_trs
LEfT JOIN
  `bigquery-public-data.ethereum_blockchain.contracts` AS contracts
ON
  (contracts.address = token_trs.token_address)
WHERE
  token_trs.token_address = '0x41dbecc1cdc5517c6f76f6a6e836adbee2754de3'   

In case if you for some reason need JOIN to work - run first below query to obtain the address that is present in both tables

#standardSQL
SELECT contracts.address
FROM `bigquery-public-data.ethereum_blockchain.token_transfers` AS token_trs
JOIN `bigquery-public-data.ethereum_blockchain.contracts` AS contracts
ON contracts.address = token_trs.token_address
LIMIT 10   

Take any address from result and run your original query with it

For example:

#standardSQL
SELECT
  from_address,
  to_address,
  value,
  transaction_hash
FROM
  `bigquery-public-data.ethereum_blockchain.token_transfers` AS token_trs
JOIN
  `bigquery-public-data.ethereum_blockchain.contracts` AS contracts
ON
  (contracts.address = token_trs.token_address)
WHERE
  contracts.address = '0x298683bd77f17bca4f3fb37b5bf02f82ee81d3ef'

Note: I see extra spaces in your address value - most likely copy paste issue but wanted to mention

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!