Copy table column A to table B sql

1

Good afternoon, folks,

I have two tables and I need to do a SELECT to bind the code of cities that are in table B to the cities of table A.

I'm using the query:

select
  a.Cidade,
  b.Cidade,
  b.cod
from
  tabelaA a left join tabelaB b on (a.cidade = b.cidade)

Please, I could help, thank you.

I use the SQL SERVER 2017 Express database

    
asked by anonymous 08.08.2018 / 23:04

1 answer

1

SOLVED !!! In fact table A has 'N' number of cities, and they repeat several times, being that two cities can have the same name in different states, so my query returned a greater amount of registers, I decided comparator not only the city, but also the state in which each city belongs, worked out with the query above, I just added the comparison of city by state. Thank you.

    
09.08.2018 / 02:25