SELECT users.* FROM users
JOIN users AS parent
ON parent.username = 'Joe'
WHERE users.ip = parent.ip;
这是对的吗?
如何在同一个表格中选择:
SELECT article.* FROM article
JOIN users
ON users.username = 'Joe' OR users.ip = (????? maybe users.ip)
WHERE article.owner = users.username;
感谢。
答案 0 :(得分:1)
我认为你必须交换ON和WHERE子句的内容:
SELECT * FROM article
JOIN users
ON article.owner = users.username
WHERE users.username = 'Joe' OR users.ip = (????? maybe users.ip);
ON子句根据两个表连接的条件确定