2
Contributors
2
Replies
3
Views
4 Years
Discussion Span
Last Post by xXghostXx
0

thanks and here an example done by me if there are any more example please post it

CREATE TABLE Persons
(
P_Id int NOT NULL PRIMARY KEY,
FirstName varchar(255),
LastName varchar(255) NOT NULL,
Address varchar(255),
City varchar(255) DEFAULT 'unknown'
);

CREATE TABLE Orders
(
O_Id int NOT NULL,
P_Id int,
OrderName varchar(255),
PRIMARY KEY (O_Id),
FOREIGN KEY (P_Id) REFERENCES Persons(P_Id)
);

insert into persons values ('1','sara','lala','street10','de');
insert into persons values ('2','toto','no','street10','nl');
insert into persons values ('3','momo','yes','street10','ch');
insert into persons values ('4','bobo','yea','street10','sy');
insert into persons values ('5','malk','tata','street10','sy');
insert into persons (P_Id,FirstName,LastName,Address) values ('6','yuo','zoo','street10');


insert into Orders values ('1','1','Order1');
insert into Orders values ('2','1','Order2');
insert into Orders values ('3','2','Order3');
insert into Orders values ('4','3','Order4');
insert into Orders values ('5','3','Order5');
insert into Orders values ('6','3','Order6');
insert into Orders (O_Id,OrderName) values ('7','Order7');
insert into Orders (O_Id,OrderName) values ('8','Order8');
insert into Orders (O_Id,OrderName) values ('9','Order9');

query
select persons.firstname,orders.ordername from persons inner join orders on persons.p_id=orders.p_id 
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.