#1066 - Not unique table/alias:

后端 未结 2 556
别跟我提以往
别跟我提以往 2021-01-16 10:44

Can you please help me out. I have this SQL query:

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          


        
相关标签:
2条回答
  • 2021-01-16 11:34
    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

    0 讨论(0)
  • 2021-01-16 11:37

    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.

    0 讨论(0)
提交回复
热议问题