2024-04-24 16:50:11 发布
网友
我有一个表profiles,其中包含具有主键login_hash的人和一堆其他字段(例如age)。另一个表msgs包含src和dest字段,这两个字段都是profiles表中login_hash的外键。如何在一个sqlite3(来自Python)查询中检索src和dests的年龄?你知道吗
profiles
login_hash
age
msgs
src
dest
可以使用两个内部联接:
SELECT m.*, p1.*, p2.* FROM msgs m INNER JOIN profiles p1 ON m.src = p1.login_hash INNER JOIN profiles p2 ON m.dest = p2.login_hash
可以使用两个内部联接:
相关问题 更多 >
编程相关推荐