python - Retrieve same column data from two different rows with one sqlite3 query? -
i have table profiles containing people primary key login_hash , bunch of other fields (for example, age). table, msgs, contains src , dest fields, both of foreign keys login_hash profiles table. how retrieve ages of src , dests in 1 sqlite3 (from python) query?
you can use 2 inner joins:
select m.*, p1.*, p2.* msgs m inner join profiles p1 on m.src = p1.login_hash inner join profiles p2 on m.dest = p2.login_hash
Comments
Post a Comment