Where clause
How to select records from two tables using select statement with where clause.
Students table:
| ID | NAME | CITY |
|---|---|---|
| 1 | Emma | New York |
| 2 | Daniel | Chicago |
| 3 | Joseph | Dallas |
| 4 | Jennifer | Los Angeles |
| 5 | Debra | Dallas |
Library table:
| ID | TITLE | STUDENT_ID |
|---|---|---|
| 1 | SQL | 3 |
| 2 | T-SQL | 1 |
| 3 | MSSQL | 5 |
Select from two tables
select s.ID, s.Name, l.Title
from Students s, Library l
where s.ID=l.Student_id;
Results
| ID | NAME | TITLE |
|---|---|---|
| 1 | Emma | T-SQL |
| 3 | Joseph | SQL |
| 5 | Debra | MSSQL |