X
X
xxxfdd2021-12-19 13:52:17
Python
xxxfdd, 2021-12-19 13:52:17

How to compare rows in two different tables?

I have two tables. These two tables have the same column names, I need to compare a row from the first table where id = 1 and a row from another table where id is 1, and if all the values ​​​​match, display it fits how it can be done, nothing comes to mind

Answer the question

In order to leave comments, you need to log in

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

SELECT *
    FROM table1 AS t1
    LEFT JOIN table2 AS t2
        ON t1.id = t2.id
    WHERE 
        t1.id = ? AND
        row_to_json(t1.*) @> row_to_json(t2.*) AND
        row_to_json(t1.*) <@ row_to_json(t2.*);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question