SQLite Forum

.expert Error: ON clause references tables to its right
Login
Exactly.  You can get around this by complying with standard SQL requirements and make sure that tables used in the ON-clause syntactic sugar have already been "introduced" before they are "used".

That is:

```
   select *
     from a
left join b 
       on a.a = b.a
      and c.b = b.b
left join c
       on a.c = c.c
;
```

is mis-stated, however, it can be solved by "advanced query optimization".  The correct statement would be:

```
   select *
     from a
left join c
       on a.c = c.c
left join b
       on a.a = b.a
      and c.b = b.b
;
```

Both forms will produce "the same result".  Technically, however, one cannot "solve" the first query as stated without re-ordering the tables.