【发布时间】:2021-03-24 18:31:38
【问题描述】:
我的数据库中有以下 2 个表。
tbl_customers
cid (int auto)
name (text)
tbl_contacts
cid
email
name
phone
我正在尝试在 peewee 中编写以下 sql 查询,但无法正常工作
SELECT tbl_customers.cid, tbl_contacts.name
FROM tbl_customers
INNER JOIN tbl_contacts ON tbl_customers.cid = tbl_contacts.cid
WHERE tbl_customers.cid = '5';
我正在尝试让数据像这样显示
tbl_customer.cid = 5
tbl_contacts.name = 'Test User'
根据我发现的谷歌搜索,我在 peewee 中尝试了以下操作。
tbl_customers.select(tbl_customers.cid, tbl_contacts.name).join(tbl_contacts, on=(tbl_customers.cid == tbl_contacts.cid)).where(tbl_customers.cid == '5')
【问题讨论】:
标签: peewee