SQL Foreign Tables and Attributes

Asked

Viewed 50 times

-4

Good afternoon, I made an 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 sex is M and the center neighborhood.

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

  • 1

    Also put the code of your attempt so we can help.

  • Come on. You have a student, and a student. each of a sex, and a neighborhood rum you want the male student, and living in the center. what you want from these students beyond the demands ?

  • Hello, Lucas. If the answer answered your question, please accept it.

1 answer

0

select cdaluno, nmaluno
from Aluno inner join Bairro on Aluno.cdbairro = Bairro.cdbairro
where sexo = 'M' and nmbairro = 'CENTRO'

Browser other questions tagged

You are not signed in. Login or sign up in order to post.