我想从数据库中选择一行并加入该行。当我使用此命令时,它工作正常:
SELECT p.* FROM pages AS p JOIN products AS pro ON pro.page_id = p.id
但是当执行以下命令时,我得到了一个错误:
select p.* from pages as p where p.id = 21605 join products as pro on pro.page_id = p.id
为什么会这样?我怎样才能把结果传给第二个命令?
nc1teljy1#
你的语法不正确
SELECT p.* FROM pages AS p JOIN products AS pro ON pro.page_id = p.id WHERE p.id = 21605
或
SELECT T.* FROM (SELECT p.* FROM pages AS p WHERE p.id = 21605) AS T JOIN products AS pro ON pro.page_id = T.id
1条答案
按热度按时间nc1teljy1#
你的语法不正确
或