Hi list,
I have the following schema:
CREATE TABLE a(id int primary key);
CREATE TABLE b(id int primary key);
I want to find information about a particular id, and my query boils
down to something like
select * from a left natural join (select * from b) where id = 1;
(in the real code, t
Simon Slavin writes:
> On 9 Dec 2011, at 10:25pm, Nick Smallbone wrote:
>
>> select * from a left natural join (select * from b) where id = 1;
>
> Try not to use sub-selects when you can use a JOIN instead.
> Especially don't use them in combination. If you exp
"Black, Michael (IS)"
writes:
> Natural joins are generally considered to be evil. Too many columns
> in common can be bad.
>
> If you just spell it out it works as expected
>
> sqlite> explain query plan select * from a left join b where a.id=1 and
> b.id=a.id;
> 0|0|0|SEARCH TABLE a USING COV
Simon Slavin writes:
> I understand that SQLite handles VIEWs as if you had defined and saved
> a SELECT statement. So if you JOIN with a VIEW, does SQLite handle it
> as as JOIN or a sub-SELECT ?
It's just the same as if you JOIN with a sub-SELECT (the query for the
view), as far as I can tell.
"Black, Michael (IS)"
writes:
> Why do you have a subselectwhat are you doing there that you can't
> do in the "on" clause?
In the "real" example I'm joining with a view:
create view v as select * from b where ...
select * from a left natural join v where id = 1;
IIUC, when I execute th
5 matches
Mail list logo