T-SQL Tutorial

Select from two tables T-SQL


Where clause

How to select records from two tables using select statement with where clause.

Students table:

IDNAMECITY
1EmmaNew York
2DanielChicago
3JosephDallas
4JenniferLos Angeles
5DebraDallas

Library table:

IDTITLESTUDENT_ID
1SQL3
2T-SQL1
3MSSQL5

Select from two tables

select s.ID, s.Name, l.Title
from Students s, Library l
where s.ID=l.Student_id;

Results

IDNAMETITLE
1EmmaT-SQL
3JosephSQL
5DebraMSSQL