2

I am not sure that is a "SELECT/JOIN" problem but I really don't know how to formulate the question. Perhaps you could suggest a better title

I have a table (table-a) with a list of items, I Want to associate the information of table-B.col2 when it is equal to "1"

What query should I write?

Table A   
Col1
AAA
BBB            
DDD
EEE                        
                          AAA 1
Table B      =====>       BBB         
Col1  Col2                DDD 1
AAA   1                   EEE
AAA   2   
BBB   2
CCC   1
CCC   3
DDD   1
FFF   1
2
4

This is a simple "filtered" outer join:

select a.col1, b.col2 
from table_a a
  left join table_b b on a.col1 = b.col1 and b.col2 = 1
1
  • Thank you very much I am just starting using DB, I didn't knew the "LEFT" usage. – Emmanuel Nov 19 '15 at 14:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.