The INNER JOIN keyword joins two tables and returns the rows when there is at least one match in both tables.
Example of the inner join
Create Table Person
(
P_Id int NOT NULL,
LastName VARCHAR(225),
FirstName VARCHAR(225),
City VARCHAR(225),
PRIMARY KEY(P_Id)
)
Create Table Order
(
O_Id int NOT NULL,
OrderNo int,
P_Id int ,
PRIMARY KEY(O_Id)
FOREIGN KEY(P_Id) REFERENCES PERSON(P_Id)
)
select Person.LastName, Person.FirstName , Person.City,
Order.OrderNo From Person
inner join Order
ON Person.P_Id = Order.P_Id
Order By Person.LastName;
the above example , selecting from two table Person, Orders and equating condition with P_Id , and if this condition satisfies then it will return a record .

0 comments:
Post a Comment