Rickey
Rickey

Reputation: 1

Need help with sql query

Table 1
id - name
1  - ric
2  - joe
3  - harry
4  - james

Table 2 
sno - Tbl_1_Id - notes
1   - 1        - abcdef
2   - 4        - xyzzz

I want the result to be

id - name - notes
1  - ric  - abcdef
2  - joe  - 
3  - harry- 
4  - james- xyzzz

Upvotes: 0

Views: 39

Answers (2)

Johan
Johan

Reputation: 76537

Use a left join.

SELECT t1.id, t1.name, t2.notes FROM 
table1 as t1 
LEFT JOIN table2 as t2 ON (t1.id = t2.tbl_1_id)

Upvotes: 2

Akhil
Akhil

Reputation: 7600

SELECT   t1.id, t1.name, t2.notes
FROM     Table1 t1
         LEFT OUTER JOIN Table2 t2 ON t1.id = t2.Tbl_1_Id 

Upvotes: 2

Related Questions