D
D
dienerie2020-11-11 10:08:14
SQL
dienerie, 2020-11-11 10:08:14

How to find discrepancies in two MYSQL tables?

There are two tables.
Both have two identical fields.

Table 1
field product_identificator
field count

field features
field price

Table 2
field product_identificator
field count

field remains

We need to find records that have discrepancies in the count field, that is, in theory, the values ​​​​should correspond to each other, and with this query I want to find discrepancies

Answer the question

In order to leave comments, you need to log in

3 answer(s)
V
Vladimir Kuts, 2020-11-11
@fox_12

Is something like this not working?

SELECT * 
FROM Таблица 1 AS t1 
LEFT JOIN Таблица 2 AS t2 
ON t1.product_identificator=t2.product_identificator 
WHERE t1.count <> t2.count

A
Alex, 2020-11-11
@libalex

I'm guessing something like:

select table1.product_identificator, table1.count from table1 left join table2 on table1.product_identificator = table2.product_identificator where table1.count != table2.count;

V
Vitaly Voloboev, 2020-11-11
@VitaliiVV

(SELECT product_identificator, count
FROM Table 1
EXCEPT
SELECT product_identificator, count
FROM Table 2)
UNION
(SELECT product_identificator, count
FROM Table 2
EXCEPT
SELECT product_identificator, count
FROM Table 1)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question