silverkid
silverkid

Reputation: 9563

joining all columns of two tables in mysql conditionally

Mysql database has a tableA which has a many columns . one of the columns is SIM1. Another table is tableB which has many columns . one of the columns is SIM2 the requirement is to join all columns of tableA and tableB given that SIM1 = SIM2.

LIKE THIS

tableA

col1   col2  SIM1 ..........col24
a       x     1             5 
b       y     1             3
c       z     0             2
d       g     2             1

tableB

colA   colB   SIM2
x       g     1
y       f     0
x       s     0
y       e     2

The result of Select query should be

col1   col2  SIM1............col24  colA  colB  SIM2
a       x     1   ........... 5      x     g     1
c       z     0   ......... . 2      x     s     0
d       g     2    .......... 1      y     e     2

is it possible?

Upvotes: 0

Views: 8647

Answers (1)

Pablo Santa Cruz
Pablo Santa Cruz

Reputation: 181270

select * from tableA inner join tableB on tableA.SIM1 = tableB.SIM2

Upvotes: 5

Related Questions