MySQL #1066 - 不是唯一的表/别名:
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19590007/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
#1066 - Not unique table/alias:
提问by Jason
Can you please help me out. I have this SQL query:
你能帮我一下吗。我有这个 SQL 查询:
SELECT l.url
FROM (b INNER JOIN links ON b.parent_id = l.id)
INNER JOIN b ON l.id = b.link
WHERE l.url LIKE 'http://domain%' LIMIT 0, 30
And somehow it says
不知何故它说
#1066 - Not unique table/alias: b
回答by Daniel Hilgarth
You seem to be selecting from the same table twice. Each of these occurrences needs its own alias:
您似乎从同一张表中选择了两次。这些事件中的每一个都需要自己的别名:
SELECT
l.url
FROM
b as b1 /* <-- */
INNER JOIN links as l
ON b1.parent_id = l.id
INNER JOIN b as b2 /* <-- */
ON l.id = b2.link
WHERE l.url LIKE 'http://domain%' LIMIT 0, 30
Please note that I also added the missing alias l
for the links
table.
请注意,我还l
为links
表添加了缺失的别名。
回答by user3864045
SELECT l.url from b inner join links as l on l.id = l.parent_id
inner join b as b1 on b1.link = l.id
where l.url like 'http:domain%' limit 0,30
In this query we r join two table first b and second links and self join b as b1 alias ok
在此查询中,我们 r 连接两个表,第一个 b 和第二个链接,并自连接 b 作为 b1 别名 ok