Foreign SQL Tables and Attributes

-4

Good afternoon, I made a Sql code with the following tables:

create table Bairro(
    cdbairro int not null primary key,
    nmbairro varchar(80) not null
)default charset = utf8;


create table Aluno(
    cdaluno int not null primary key,
    nmaluno varchar(80) not null,
    sexo enum('M', 'F'),
    cdcursocur int,
    cdrua int,
    numeroaluno int not null,
    cdbairro int,
    cdcidade int,
    dtnascimentoaluno varchar(15) not null,

    foreign key (cdcursocur) references CursoCur(cdcursocur),
    foreign key (cdrua) references Rua(cdrua),
    foreign key (cdbairro) references Bairro(cdbairro),
    foreign key (cdcidade) references Cidade(cdcidade)
)default charset = utf8;

Then my teacher requested the following item:

  

Show all students whose gender is M and the downtown district.

I would like to know how I can resolve this item as I have tried and failed.

    
asked by anonymous 28.11.2018 / 19:13

1 answer

0
select cdaluno, nmaluno
from Aluno inner join Bairro on Aluno.cdbairro = Bairro.cdbairro
where sexo = 'M' and nmbairro = 'CENTRO'
    
28.11.2018 / 19:53