JOIN सिंटैक्स
select username from table1 join table2 on table1.id = table2.fk_id;
उदाहरण
टेबल 1 (demo77): userid (PK), username
mysql> create table demo77 (userid int not null primary key, username varchar(20)); mysql> insert into demo77 values(1,'John'), (2,'Bob'), (3,'Mike');
टेबल 2 (demo78): id (PK, FK→demo77), countryname
mysql> create table demo78 (id int not null primary key, countryname varchar(20), constraint fk_id foreign key(id) references demo77(userid)); mysql> insert into demo78 values(1,'US'), (2,'AUS');
JOIN क्वेरी और परिणाम
mysql> select username from demo77 join demo78 on demo77.userid=demo78.id;
+----------+ | username | +----------+ | John | | Bob | +----------+
नोट: FK कंस्ट्रेंट डेटा अखंडता सुनिश्चित करता है।