Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQL Query Concatenate two columns during Inner JOIN

I have table A and table B with Table A having several columns including A1 and A2. Table B too has several columns. My query requires me to concatenate the values in A1 and A2 and then do an inner join on B1.

Example:

Select * 
From A
INNER JOIN B
ON CONCAT(A1,A2) = B1.

Apparently this is not how it should work. Can someone please give me a hand in this query?

Thanks.

like image 537
Niras Avatar asked Mar 22 '12 18:03

Niras


1 Answers

Try this:

Select *  
From A 
INNER JOIN B 
ON A1 + A2 = B1
like image 122
Andrey Gurinov Avatar answered Sep 28 '22 00:09

Andrey Gurinov