'BQ SQL join with a table with a name that is derived from a query

I have some fields that are a date. That date then is then used to look up a table with a name corresponding to the date of that field. I'm doing a join to get other fields, but the question is how to treat the field with the date as a variable that can be used then to perform the join.

Here is the example query:

with tab1 as (
    select 
        product_id, 
        start_date, 
    from `project.user.table`
) 

select * from tab1 inner join `project2.table2.{start_date}` as B on tab1.product_id = B.p_id

After suggestions I have tried the following query to tighten things up, but it is sadly not working.

with tab1 as (
    select 
        cast(product_id as INT64) as product_id_64, 
        cast(FORMAT_DATE('%Y%m%d', CAST(start_date AS DATE)) as STRING) as start_date_string
        
    from `project.user.table`
) 

select * from `user2.dataset.*` b
inner join tab1 
on b._TABLE_SUFFIX = tab1.start_date_string

led to the following error:

Error running query. Cannot read field of type STRING as INT64 Field: GTIN


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source