ashays - 6 months ago 23

SQL Question

Given a database with two tables

`X`

`Y`

`LEFT JOIN`

`X.a1`

`Y.b1`

`SELECT X.a1, X.a2, Y.b1, Y.b2 FROM X LEFT JOIN Y ON (X.a1 = Y.b1)`

I thought that would be good enough to work, even if

`Y`

`Y`

`Y`

`LEFT JOIN`

`Y`

`X`

`LEFT JOIN`

Answer

Your table names are a little confusing. Is it X and Y, or X.a and Y.b?

If X and Y:

```
SELECT X.a1, X.a2, Y.a1, Y.b2 FROM X LEFT OUTER JOIN Y ON (X.a1 = Y.b1)
```

should bring back all X, with nulls for the Y.a1 and Y.b2 where there is no matching record.