开发者

joining all columns of two tables in mysql conditionally

开发者 https://www.devze.com 2022-12-14 10:57 出处:网络
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

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?


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

精彩评论

暂无评论...
验证码 换一张
取 消