Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

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:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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

>Solution :

SELECT T.*
FROM TABLE_B AS T
JOIN TEMP_TABLE AS A ON T.COL_1=A.ID
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading