Home > Mobile >  How can I run the SQL like "SELECT * from table where columnA = temp_table_result"?
How can I run the SQL like "SELECT * from table where columnA = temp_table_result"?

Time:06-14

I have a temp_table defined as:

with temp_table as (
  select id from table_A where name="john" limit 1
)

This table returns 1 row with just the id I want to select all rows in table_B where the column col_1 is equal to the result of temp_table:

Both of the following fail for me:

select * from table_B where col_1 = temp_table
select * from table_B where col_1 = temp_table.id

CodePudding user response:

SELECT T.*
FROM TABLE_B AS T
JOIN TEMP_TABLE AS A ON T.COL_1=A.ID
  • Related