简体   繁体   中英

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

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
SELECT T.*
FROM TABLE_B AS T
JOIN TEMP_TABLE AS A ON T.COL_1=A.ID

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM