N
N
NAbrakadabra2014-04-04 13:09:17
SQL
NAbrakadabra, 2014-04-04 13:09:17

SQL query: how to make a selection from two databases by mismatches?

There are two bases, the number of rows is the same. How to select rows with three matching elements (full name) from both bases and leave only those in which the fourth element (ID) differ?
ps
Urgently needed in the work, I know the .SQL query language at the initial level of select-from-where.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexander, 2014-04-04
@Papagatto

select * from db1.table t1
   inner join db2.table t2
    on t1.f = t2.f
   and t1.i = t2.i
   and t1.o = t2.o
 and t1.id != t2.id

S
svd71, 2014-04-04
@svd71

select * from database1.users u1, database2.users u2
where
  u1.family=u2.family and u1.firstname=u2.firstname and u1.lastname=u2.lastname 
  and u1.id <> u2.id

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question