compare two rows of different tables and get the same MySQL records

0

I have two tables with the same fields but each user inserts different records (there is a range of 78 possible records that each user can insert in their table) what I want to be able to do is to obtain in which fields the records are similar and in which they are not (since there is a possibility that the records inserted in the tables of the 2 users are similar or not similar)

I want to get a row that shows in which fields the records of the two tables of the two users are equal. when they are equal to show the same records and when they are not showing a "NULL".

    
asked by gabo luna 19.06.2017 в 17:54
source

2 answers

1

TableA (Col1, Col2) TablaB (Col1, Col2)

SELECT * FROM TablaA as A
INNER JOIN TablaB as B
    ON (A.Col1 = B.Col1 and A.Col2 = B.Col2)

In the sentence, you can see that I compare column1 of Table A with column 1 of Table B, the same with the other column. If you execute the query, the UNICOS records that match in their respective columns with the other table will be reflected. I hope you serve, greetings.

    
answered by 19.06.2017 в 18:12
0

I do not understand so that 2 tables with the same fields, maybe you could do in the same table add a field that differentiates them, eg: type of movement, type of operation, etc.

personally having 2 tables with the same data is not very good practice.

You could send your tables and see how to relate them.

greetings

    
answered by 19.06.2017 в 23:14