Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
SELECT id, subject FROM pages AS a INNER JOIN articles AS b ON a.subject = b.id WHERE a.id = ?
它不起作用,它说:
一般错误:1 不明确的列名:id。
但是我为表页(a)做了一个别名,并在 WHERE 子句中使用了它。那为什么会模棱两可呢?
表页有id,subject和其他一些列。该subject列应链接到id另一个表的列,articles
id
subject
articles
您需要在列名之前使用别名,尝试添加它们
SELECT a.id, a.subject FROM pages AS a INNER JOIN articles AS b ON a.subject = b.id WHERE a.id = ?
请注意,使用a.id您id将从表中获取列pages,如果您想id从表中获取,articles只需更改为b.id
a.id
pages
b.id