Page 1 of 1

Preserving rows in SQL join

Posted: Wed Feb 05, 2003 6:15 pm
by kevin31
Suppose I have two tables like the following:

Table1
ID Name
1 Fred
2 Bob
3 Sue

Table 2
ID Initial
2 B

I would like to join these such that each row in Table1 is preserved and includes the Initial value from Table2 if it exists, i.e.
JoinTable
ID Name Inital
1 Fred NULL
2 Bob B
3 Sue NULL

Can I do this? What would the query be? Thanks!

Preserving rows in SQL join

Posted: Wed Feb 05, 2003 6:44 pm
by kevin31
Suppose I have two tables like the following:

Table1
ID Name
1 Fred
2 Bob
3 Sue

Table 2
ID Initial
2 B

I would like to join these such that each row in Table1 is preserved and includes the Initial value from Table2 if it exists, i.e.
JoinTable
ID Name Inital
1 Fred NULL
2 Bob B
3 Sue NULL

Can I do this? What would the query be? Thanks!

Preserving rows in SQL join

Posted: Wed Feb 05, 2003 8:12 pm
by mark
Use nested SQL.
<sql row "select ... from table1">
<$Initial="">
<sql row "select .... from table2 where ID=$ID">
</sql>
</sql>