On 30/09/2014, at 12:04 pm, Paul Sanderson <sandersonforens...@gmail.com> wrote:

> I two tables of the form
> 
> create table1 (person1 text, person2 text)
> create table2 (person text, picture blob)
> 
> Is it possible to create a join so I can get a resultant dataset of the form
> 
> person1, person1picture, person2, person2picture

SELECT person1, p1.picture, person2, p2.picture FROM table1 JOIN table2 AS p1 
ON table1.person1 = p1.person JOIN table2 AS p2 ON table1.person2 = p2.person;

The trick is to use table aliases (AS) to allow joining twice to the same table 
with different criteria, and then picking columns from the appropriate instance.

_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to