JOINning two tables provides no data

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

JOINning two tables provides no data

Jose Isaias Cabrera-4

Greetings!

Imagine this scenario,

create table a (a, b, c);
create table b (a, d, e);
insert into a values (1, 2, 3);
insert into a values (2, 3, 4);
insert into a values (3, 4, 5);
select a.a, a.b, a.c, b.d, b.e as q from a join b on a.a=b.a where a.a = 1;

sqlite> select a.a, a.b, a.c, b.d, b.e as q from a join b on a.a=b.a where a.a = 1;
sqlite>

This provides no result.  I expected to get,

1|2|3||

If I add this insert,

insert into b values (1, 4, 5);

and do the same select,

sqlite> select a.a, a.b, a.c, b.d, b.e as q from a join b on a.a=b.a where a.a = 1;
1|2|3|4|5
sqlite>

Is there a way to do a select and get

1|2|3||

Or do I have to insert values to the b table?  Thanks.

josé
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: JOINning two tables provides no data

J. King-3
On January 18, 2019 12:54:32 PM EST, Jose Isaias Cabrera <[hidden email]> wrote:
>
>sqlite> select a.a, a.b, a.c, b.d, b.e as q from a join b on a.a=b.a
>where a.a = 1;
>sqlite>
>
>This provides no result.  I expected to get,
>
>1|2|3||


You appear to seek the result of a LEFT JOIN.
--
J. King
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: JOINning two tables provides no data

Jose Isaias Cabrera-4

Darn ti!  Thanks.


On Saturday, January 19, 2019 07:20 AM, J. King wrote,

>On January 18, 2019 12:54:32 PM EST, Jose Isaias Cabrera <[hidden email]> wrote:
>>
>>sqlite> select a.a, a.b, a.c, b.d, b.e as q from a join b on a.a=b.a
>>where a.a = 1;
>>sqlite>
>>
>>This provides no result.  I expected to get,
>>
>>1|2|3||
>
>
>You appear to seek the result of a LEFT JOIN.

Yep, that's it. Thanks.

josé
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users