Home SELECT same element from two tables
Reply: 0

SELECT same element from two tables

user1098
1#
user1098 Published in April 20, 2018, 10:50 am

I got these two tables:

Create table  Consumidor  (
    numero  int(9),
    email   varchar(30) not null,
    sexo    char(1) not null,
    nascimento  date    not null,
    constraint Consumidor_sexo_RI001     check (sexo in ('F','M')),
    constraint Consumidor_unique_RI002  unique(email),
    constraint pk_Consumidor     primary key (numero)
);

Create table  Dependente  (
    consumidor  int(9),
    numero  int(2),
    sexo    char(1) not null,
    nascimento  date    not null,
    constraint Dependente_sexo_RI003 check (sexo in ('F','M')),
    constraint fk_Dependente_consumidor  foreign key (consumidor) references Consumidor(numero) on delete cascade,
    constraint pk_Dependente     primary key (consumidor,numero)
);

What I wanna do is SELECT the 'sexo' and 'nascimento' of both tables. I don't understand how I can do this.

------------------ EDIT ----------------------- The result table should look something like this:

idade | sexo
  34  |  F

It only has two columns for both tables.

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.31484 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO