user1036077
user1036077

Reputation: 9

SQL JOIN Statement

Select name_A,name_B 
 From 
 A inner join B on A.Id_a = B.Id_a 

this returns the values based on the A.Id_a = B.Id_a but I have also records in table A which are not related to table B which i want to read out as the same time. In this case I want to read all name_A and name_B based on A.Id_a = B_a.Id. Any Idea

Upvotes: 1

Views: 227

Answers (3)

xQbert
xQbert

Reputation: 35343

I'm a visual person so I find http://www.codinghorror.com/blog/2007/10/a-visual-explanation-of-sql-joins.html very handy from time to time.

Both answers above are correct an OUTER join LEFT or right depending on which table is listed first is required.

Upvotes: 0

Royi Namir
Royi Namir

Reputation: 148744

Select name_A,name_B 
 From 
 A left join B on A.Id_a = B.Id_a 

Upvotes: 0

Icarus
Icarus

Reputation: 63970

Do a left join:

Select name_A,name_B 
 From 
 A left  join B on A.Id_a = B.Id_a

Upvotes: 3

Related Questions