3 回答

TA貢獻(xiàn)1827條經(jīng)驗(yàn) 獲得超8個(gè)贊
您應(yīng)該從我猜的連接查詢(xún)中選擇書(shū)籍詳細(xì)信息:
select books.* from books join orders on books.isbn = orders.isbn
where orders.user_id = ?;

TA貢獻(xiàn)1848條經(jīng)驗(yàn) 獲得超2個(gè)贊
因此,您擁有的是一個(gè)帶有書(shū)籍詳細(xì)信息和 ISBN 號(hào)的表格以及另一個(gè)帶有用戶(hù)和 ISBN 號(hào)的表格。因此,獲取本書(shū)詳細(xì)信息的最簡(jiǎn)單方法是:
cur.execute("select booktable.bookdetails from booktable A, UserTable B
where A.ISBNno = B.ISBNno
and B.userID = %s", [user_id])
或者如果你想要所有的列
cur.execute("select booktable.* from booktable A, UserTable B
where A.ISBNno = B.ISBNno
and B.userID = %s", [user_id])

TA貢獻(xiàn)1830條經(jīng)驗(yàn) 獲得超9個(gè)贊
這將做同樣的select books.* from books where isbn in (select isbn from orders where user_id = ?)
......
添加回答
舉報(bào)