A
A
AlexBoss2021-11-15 21:46:31
PostgreSQL
AlexBoss, 2021-11-15 21:46:31

How to make a selection of table records by condition for values ​​from a linked table?

Good afternoon. Let's say there are 2 tables, one-to-many or many-to-many relationship. How to make a selection to delete or change values ​​in the main table, using the conditions for the filter from the field of the dependent (other) table?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Tomulevich, 2021-12-13
@phoinixrw

DELETE FROM table1
    WHERE id IN ( 
        SELECT t1.id 
            FROM table1 AS t1 
            INNER JOIN table2 AS t2 
                ON ...
            WHERE ... )

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question